從底向上第七篇--超255列表的儲存

sundog315發表於2010-06-21
從底向上第一篇--瞭解DML操作
從底向上第二篇--瞭解行遷移
從底向上第三篇--瞭解index的compress
從底向上第四篇--瞭解行連結
從底向上第五篇--瞭解表的壓縮屬性
從底向上第六篇--compress for oltp真正壓縮的閾值觸發條件
從底向上第七篇--超255列表的儲存

先生成一個256列的表,並把資料dump出來:

CODE:

SQL> declare
  2    -- Local variables here
  3    i integer;
  4    vSQL varchar2(32767);
  5  begin
  6    -- Test statements here
  7    execute immediate 'create table t (a001 varchar2(10)) pctfree 90';
  8
  9    for i in 2..256 loop
10      execute immediate 'alter table t add a'||lpad(i,3,'0')||' varchar2(10)';
11    end loop;
12
13    vSQL := 'insert into t values (';
14    for i in 1..256 loop
15      vSQL := vSQL || to_char(i) ||',';
16    end loop;
17
18    vSQL := substr(vSQL,0,length(vSQL)-1)||')';
19
20    execute immediate vSQL;
21
22    commit;
23  end;
24  /

PL/SQL 過程已成功完成。

SQL> alter system checkpoint;

系統已更改。

SQL> alter system dump datafile 4 block 132;

系統已更改。

SQL> alter system dump datafile 4 block 133;

系統已更改。*** 2010-06-13 16:01:59.477
Start dump data blocks tsn: 4 file#:4 minblk 132 maxblk 132
F649E60 08C50001 04010000 3201FF01 34013301  [...........2.3.4]
F649E70 36013501 38013701 31023901 31310230  [.5.6.7.8.9.10.11]
F649E80 02323102 31023331 35310234 02363102  [.12.13.14.15.16.]
F649E90 31023731 39310238 02303202 32023132  [17.18.19.20.21.2]
F649EA0 33320232 02343202 32023532 37320236  [2.23.24.25.26.27]
F649EB0 02383202 33023932 31330230 02323302  [.28.29.30.31.32.]
F649EC0 33023333 35330234 02363302 33023733  [33.34.35.36.37.3]
F649ED0 39330238 02303402 34023134 33340232  [8.39.40.41.42.43]
F649EE0 02343402 34023534 37340236 02383402  [.44.45.46.47.48.]
F649EF0 35023934 31350230 02323502 35023335  [49.50.51.52.53.5]
F649F00 35350234 02363502 35023735 39350238  [4.55.56.57.58.59]
F649F10 02303602 36023136 33360232 02343602  [.60.61.62.63.64.]
F649F20 36023536 37360236 02383602 37023936  [65.66.67.68.69.7]
F649F30 31370230 02323702 37023337 35370234  [0.71.72.73.74.75]
F649F40 02363702 37023737 39370238 02303802  [.76.77.78.79.80.]
F649F50 38023138 33380232 02343802 38023538  [81.82.83.84.85.8]
F649F60 37380236 02383802 39023938 31390230  [6.87.88.89.90.91]
F649F70 02323902 39023339 35390234 02363902  [.92.93.94.95.96.]
F649F80 39023739 39390238 30303103 31303103  [97.98.99.100.101]
F649F90 32303103 33303103 34303103 35303103  [.102.103.104.105]
F649FA0 36303103 37303103 38303103 39303103  [.106.107.108.109]
F649FB0 30313103 31313103 32313103 33313103  [.110.111.112.113]
F649FC0 34313103 35313103 36313103 37313103  [.114.115.116.117]
F649FD0 38313103 39313103 30323103 31323103  [.118.119.120.121]
F649FE0 32323103 33323103 34323103 35323103  [.122.123.124.125]
F649FF0 36323103 37323103 38323103 39323103  [.126.127.128.129]
F64A000 30333103 31333103 32333103 33333103  [.130.131.132.133]
F64A010 34333103 35333103 36333103 37333103  [.134.135.136.137]
F64A020 38333103 39333103 30343103 31343103  [.138.139.140.141]
F64A030 32343103 33343103 34343103 35343103  [.142.143.144.145]
F64A040 36343103 37343103 38343103 39343103  [.146.147.148.149]
F64A050 30353103 31353103 32353103 33353103  [.150.151.152.153]
F64A060 34353103 35353103 36353103 37353103  [.154.155.156.157]
F64A070 38353103 39353103 30363103 31363103  [.158.159.160.161]
F64A080 32363103 33363103 34363103 35363103  [.162.163.164.165]
F64A090 36363103 37363103 38363103 39363103  [.166.167.168.169]
F64A0A0 30373103 31373103 32373103 33373103  [.170.171.172.173]
F64A0B0 34373103 35373103 36373103 37373103  [.174.175.176.177]
F64A0C0 38373103 39373103 30383103 31383103  [.178.179.180.181]
F64A0D0 32383103 33383103 34383103 35383103  [.182.183.184.185]
F64A0E0 36383103 37383103 38383103 39383103  [.186.187.188.189]
F64A0F0 30393103 31393103 32393103 33393103  [.190.191.192.193]
F64A100 34393103 35393103 36393103 37393103  [.194.195.196.197]
F64A110 38393103 39393103 30303203 31303203  [.198.199.200.201]
F64A120 32303203 33303203 34303203 35303203  [.202.203.204.205]
F64A130 36303203 37303203 38303203 39303203  [.206.207.208.209]
F64A140 30313203 31313203 32313203 33313203  [.210.211.212.213]
F64A150 34313203 35313203 36313203 37313203  [.214.215.216.217]
F64A160 38313203 39313203 30323203 31323203  [.218.219.220.221]
F64A170 32323203 33323203 34323203 35323203  [.222.223.224.225]
F64A180 36323203 37323203 38323203 39323203  [.226.227.228.229]
F64A190 30333203 31333203 32333203 33333203  [.230.231.232.233]
F64A1A0 34333203 35333203 36333203 37333203  [.234.235.236.237]
F64A1B0 38333203 39333203 30343203 31343203  [.238.239.240.241]
F64A1C0 32343203 33343203 34343203 35343203  [.242.243.244.245]
F64A1D0 36343203 37343203 38343203 39343203  [.246.247.248.249]
F64A1E0 30353203 31353203 32353203 33353203  [.250.251.252.253]
F64A1F0 34353203 35353203 36353203 5DAA0601  [.254.255.256...]]
Block header dump:  0x01000084
Object id on Block? Y
seg/obj: 0x10a66  csc: 0x00.765da9  itc: 3  flg: E  typ: 1 - DATA
     brn: 0  bdba: 0x1000080 ver: 0x01 opc: 0
     inc: 0  exflg: 0

Itl           Xid                  Uba         Flag  Lck        Scn/Fsc
0x01   0x0012.003.00000272  0x03450749.0228.19  --U-    1  fsc 0x0000.00765daa
0x02   0x0000.000.00000000  0x00000000.0000.00  ----    0  fsc 0x0000.00000000
0x03   0x0000.000.00000000  0x00000000.0000.00  C---    0  scn 0x0000.00000000
bdba: 0x01000084
data_block_dump,data header at 0xf64827c
===============
tsiz: 0x1f80
hsiz: 0x14
pbl: 0x0f64827c
     76543210
flag=--------
ntab=1
nrow=1
frre=-1
fsbo=0x14
fseo=0x1beb
avsp=0x1bd7
tosp=0x1bd7
0xe:pti[0]        nrow=1        ffs=0
0x12:pri[0]        ffs=0x1beb
block_row_dump:
tab 0, row 0, @0x1beb
tl: 917 fb: -----L-- lb: 0x1  cc: 255
col  0: [ 1]  32
...
col 254: [ 3]  32 35 36

*** 2010-06-13 16:02:51.368
Start dump data blocks tsn: 4 file#:4 minblk 133 maxblk 133
F64A1F0 01012801 84000001 31010000 5DAA0601  [.(.........1...]]
Block header dump:  0x01000085
Object id on Block? Y
seg/obj: 0x10a66  csc: 0x00.765da9  itc: 2  flg: E  typ: 1 - DATA
     brn: 0  bdba: 0x1000080 ver: 0x01 opc: 0
     inc: 0  exflg: 0

Itl           Xid                  Uba         Flag  Lck        Scn/Fsc
0x01   0x0012.003.00000272  0x03450749.0228.1a  --U-    1  fsc 0x0000.00765daa
0x02   0x0000.000.00000000  0x00000000.0000.00  ----    0  fsc 0x0000.00000000
bdba: 0x01000085
data_block_dump,data header at 0xf648264
===============
tsiz: 0x1f98
hsiz: 0x14
pbl: 0x0f648264
     76543210
flag=--------
ntab=1
nrow=1
frre=-1
fsbo=0x14
fseo=0x1f8d
avsp=0x1f79
tosp=0x1f79
0xe:pti[0]        nrow=1        ffs=0
0x12:pri[0]        ffs=0x1f8d
block_row_dump:
tab 0, row 0, @0x1f8d
tl: 11 fb: --H-F--- lb: 0x1  cc: 1
nrid:  0x01000084.0
col  0: [ 1]  31
end_of_block_dump
End dump data blocks tsn: 4 file#: 4 minblk 133 maxblk 133

Oracle Database can only store 255 columns in a row piece. Thus, if you insert a row into a table that has 1000 columns, then the database creates 4 row pieces, typically chained over multiple blocks.

因為在row piece結構中,對於列數採用1個位元組(dump中每行的cc)表示,最大值為0xFF,也就是255。對於大於255列的表,會出現行連結。這樣,也就意味著讀一行資料需要多次IO。因此,對於一般的應用,最好不要超過255列,如果超過255列,不如從應用上拆分成兩個表,避免讀一個表產生過多的IO。

但是,為什麼typically chained over multiple blocks?是否Oracle的chain rows必須存在於不用的block?但是,對於chain rows,是使用nrid來查詢對應piece的,完全可以在同一block中儲存一行的多個piece。如果可以儲存在一個block中,則可以避免多次IO,對於併發也會好處理一些。

為什麼Oracle要這麼做呢?搞不清楚

[ 本帖最後由 sundog315 於 2010-6-21 10:28 編輯 ]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/19423/viewspace-665773/,如需轉載,請註明出處,否則將追究法律責任。

相關文章