|
原帖由 Yong Huang 于 2010-4-11 22:07 发表 ![]()
> 其实在11.2 Basic Compress,只要做过move,这个没有什么必要的。
Of course. But you missed the point. What "alter table compress", followed by "alter table pctfree 0" as he found out, does is to quickly modify the table attributes so future data will be compressed. "Alter table move" is a slow process (unless the segment is small) that compresses existing data.
Yong Huang
呵呵,不好意思,没看清题目。
做了一下测试,结果完全符合Yong Huang版主所说,:):
SQL> create table t as select * from dba_objects;
表已创建。
SQL> exec dbms_stats.gather_table_stats('TEST','T');
PL/SQL 过程已成功完成。
SQL> select pct_free,pct_used,blocks,empty_blocks,compression,compress_for from
user_tables where table_name='T';
PCT_FREE PCT_USED BLOCKS EMPTY_BLOCKS COMPRESS COMPRESS_FOR
---------- ---------- ---------- ------------ -------- ------------
10 1050 0 DISABLED
SQL> select header_file,header_block from dba_segments where segment_name='T';
HEADER_FILE HEADER_BLOCK
----------- ------------
4 170
SQL> alter table t compress;
表已更改。
SQL> insert /*+ append */ into t select * from dba_objects;
已创建71889行。
SQL> commit;
提交完成。
SQL> exec dbms_stats.gather_table_stats('TEST','T');
PL/SQL 过程已成功完成。
SQL> select pct_free,pct_used,blocks,empty_blocks,compression,compress_for from
user_tables where table_name='T';
PCT_FREE PCT_USED BLOCKS EMPTY_BLOCKS COMPRESS COMPRESS_FOR
---------- ---------- ---------- ------------ -------- ------------
10 1383 0 ENABLED BASIC
SQL> conn test/test
已连接。
SQL> alter system dump datafile 4 block 1382;
系统已更改。
Block header dump: 0x01000566
Object id on Block? Y
seg/obj: 0x11eec csc: 0x00.f9ac4 itc: 3 flg: E typ: 1 - DATA
brn: 0 bdba: 0x1000501 ver: 0x01 opc: 0
inc: 0 exflg: 0
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x000a.001.00000242 0x00000000.0000.00 ---- 0 fsc 0x0000.00000000
0x02 0x0000.000.00000000 0x00000000.0000.00 ---- 0 fsc 0x0000.00000000
0x03 0x0000.000.00000000 0x00000000.0000.00 ---- 0 fsc 0x0000.00000000
bdba: 0x01000566
data_block_dump,data header at 0x8f2227c
===============
tsiz: 0x1f80
hsiz: 0x328
pbl: 0x08f2227c
76543210
flag=-0------
ntab=2
nrow=367
frre=-1
fsbo=0x328
fseo=0x689
avsp=0x361 --保留了空间
tosp=0x361
r0_9ir2=0x0
mec_kdbh9ir2=0x8
76543210
shcf_kdbh9ir2=----------
76543210
flag_9ir2=--R---OC Archive compression: N
fcls_9ir2[14]={ 0 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 }
perm_9ir2[15]={ 11 13 0 14 1 12 8 9 10 2 3 4 5 6 7 }
0x42:pti[0] nrow=132 offs=0
0x46:pti[1] nrow=235 offs=132
SQL> alter table t pctfree 0;
表已更改。
SQL> insert /*+ append */ into t select * from dba_objects;
已创建71891行。
SQL> commit;
提交完成。
SQL> exec dbms_stats.gather_table_stats('TEST','T');
PL/SQL 过程已成功完成。
SQL> select pct_free,pct_used,blocks,empty_blocks,compression,compress_for from
2 user_tables where table_name='T';
PCT_FREE PCT_USED BLOCKS EMPTY_BLOCKS COMPRESS COMPRESS_FOR
---------- ---------- ---------- ------------ -------- ------------
0 1684 0 ENABLED BASIC
SQL> alter system dump datafile 4 block 1683;
系统已更改。
Block header dump: 0x01000693
Object id on Block? Y
seg/obj: 0x11efa csc: 0x00.fb271 itc: 3 flg: E typ: 1 - DATA
brn: 0 bdba: 0x1000680 ver: 0x01 opc: 0
inc: 0 exflg: 0
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0008.009.000002ef 0x00000000.0000.00 ---- 0 fsc 0x0000.00000000
0x02 0x0000.000.00000000 0x00000000.0000.00 ---- 0 fsc 0x0000.00000000
0x03 0x0000.000.00000000 0x00000000.0000.00 ---- 0 fsc 0x0000.00000000
bdba: 0x01000693
data_block_dump,data header at 0xe64827c
===============
tsiz: 0x1f80
hsiz: 0x32e
pbl: 0x0e64827c
76543210
flag=-0------
ntab=2
nrow=375
frre=-1
fsbo=0x32e
fseo=0x345
avsp=0x17
tosp=0x17
r0_9ir2=0x0
mec_kdbh9ir2=0x2a
76543210
shcf_kdbh9ir2=----------
76543210
flag_9ir2=--R---OC Archive compression: N
fcls_9ir2[9]={ 0 32768 32768 32768 32768 32768 32768 32768 2 }
perm_9ir2[15]={ 6 13 0 14 8 9 10 11 12 1 2 5 3 7 4 }
0x38:pti[0] nrow=130 offs=0
0x3c:pti[1] nrow=245 offs=130
[ 本帖最后由 sundog315 于 2010-4-12 20:14 编辑 ] |
|