|
最初由 hooman 发布
[B]
我的意思是, 如果用REVERSE 索引, 就很难做到让一个BLOCK 只能容纳一个索引指针了. 我原以为像lpad(1, 1469,'0') 这样的数据进行Reverse运算后仍然需要占用1469 BYTE 的空间, 但看起来不是这样. [/B]
上面只是在reverse index下达到了Jonathan Lewis的试验目的,再来试着解释一下hooman不能成功搭起24层的原因
重复hooman的试验
SQL> create table test2
2 (v varchar2(1469));
Table created.
SQL> create index test2_i on test2(v) reverse;
Index created.
SQL> begin
2 for i in reverse 1..24 loop
3 dbms_output.put_line(i);
4 insert into test2 values (lpad(i,1469,'0'));
5 end loop;
6 end;
7 /
PL/SQL procedure successfully completed.
SQL> select file_id,block_id ,segment_name from dba_extents
2 where segment_name='TEST2_I';
FILE_ID BLOCK_ID
---------- ----------
SEGMENT_NAME
--------------------------------------------------------------------------------
1 82465
TEST2_I
SQL> select object_name,object_id from dba_objects
2 where object_name='TEST2_I';
OBJECT_NAME
--------------------------------------------------------------------------------
OBJECT_ID
----------
T3_I
6319
SQL> alter session set events 'immediate trace name treedump level 6319';
Session altered.
SQL> analyze index test2_i validate structure;
Index analyzed.
SQL> select lf_blks,lf_rows_len,br_blks,br_rows_len from index_stats;
LF_BLKS LF_ROWS_LEN BR_BLKS BR_ROWS_LEN
---------- ----------- ---------- -----------
24 35568 1 221
首先我们发现叶子节点还是24个,所以还是一个block存放了一个index entry。但是branch node的数量大大减少了(就是根,一个),我们使用24层的例子达到的是如下
SQL> analyze index t1_i1 validate structure;
Index analyzed.
SQL> select lf_blks,lf_rows_len,br_blks,br_rows_len from index_stats;
LF_BLKS LF_ROWS_LEN BR_BLKS BR_ROWS_LEN
---------- ----------- ---------- -----------
24 35568 276 33992
所以怀疑是branch node中存放的方式发生了变化,导致可以存放多行
进一步看dump中的内容
首先看treedump的内容
----- begin tree dump
branch: 0x414222 4276770 (0: nrow: 24, level: 1)
leaf: 0x414223 4276771 (-1: nrow: 1 rrow: 1)
Leaf block dump
===============
header address 1808443484=0x6bcaa85c
kdxcolev 0
KDXCOLEV Flags = - - -
kdxcolok 1
kdxcoopc 0x80: opcode=0: iot flags=--- is converted=Y
kdxconco 2
kdxcosdc 4
kdxconro 1
kdxcofbo 38=0x26
kdxcofeo 412=0x19c
kdxcoavs 374
kdxlespl 0
kdxlende 0
kdxlenxt 4276785=0x414231
kdxleprv 0=0x0
kdxledsz 0
kdxlebksz 1892
row#0[412] flag: -----, lock: 2
col 0; len 1469; (1469):
30 31 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
col 1; len 6; (6): 00 41 41 f0 00 00
----- end of leaf block dump -----
leaf: 0x414231 4276785 (0: nrow: 1 rrow: 1)
Leaf block dump
。。。
发现果然每个叶子还是存放一条记录
dump branch node来看(这里就是root)
SQL> select dbms_utility.data_block_address_file(4276770)
2 ,dbms_utility.data_block_address_block(4276770)
3 from dual;
DBMS_UTILITY.DATA_BLOCK_ADDRESS_FILE(4276770)
---------------------------------------------
DBMS_UTILITY.DATA_BLOCK_ADDRESS_BLOCK(4276770)
----------------------------------------------
1
82466
Start dump data blocks tsn: 0 file#: 1 minblk 82466 maxblk 82466
buffer tsn: 0 rdba: 0x00414222 (1/82466)
scn: 0x0000.0000e2cd seq: 0x01 flg: 0x06 tail: 0xe2cd0601
frmt: 0x02 chkval: 0x9919 type: 0x06=trans data
Block header dump: 0x00414222
Object id on Block? Y
seg/obj: 0x18af csc: 0x00.e2cc itc: 1 flg: - typ: 2 - INDEX
fsl: 0 fnx: 0x0 ver: 0x01
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0008.006.0000012e 0x008097ff.0016.03 --U- 1 fsc 0x0000.0000e2cd
Branch block dump
=================
header address 50139204=0x2fd1044
kdxcolev 1
KDXCOLEV Flags = - - -
kdxcolok 1
kdxcoopc 0x81: opcode=1: iot flags=--- is converted=Y
kdxconco 2
kdxcosdc 1
kdxconro 23
kdxcofbo 74=0x4a
kdxcofeo 1741=0x6cd
kdxcoavs 1667
kdxbrlmc 4276771=0x414223
kdxbrsno 2
kdxbrbksz 1916
row#0[1813] dba: 4276785=0x414231
col 0; len 2; (2): 30 32
col 1; TERM
row#1[1888] dba: 4276775=0x414227
col 0; len 1; (1): 31
col 1; TERM
row#2[1741] dba: 4276794=0x41423a
col 0; len 2; (2): 31 31
col 1; TERM
row#3[1821] dba: 4276784=0x414230
col 0; len 2; (2): 31 32
col 1; TERM
row#4[1895] dba: 4276774=0x414226
col 0; len 1; (1): 32
col 1; TERM
row#5[1749] dba: 4276793=0x414239
col 0; len 2; (2): 32 31
col 1; TERM
row#6[1829] dba: 4276783=0x41422f
col 0; len 2; (2): 32 32
col 1; TERM
row#7[1902] dba: 4276773=0x414225
col 0; len 1; (1): 33
col 1; TERM
row#8[1757] dba: 4276792=0x414238
col 0; len 2; (2): 33 31
col 1; TERM
row#9[1837] dba: 4276782=0x41422e
col 0; len 2; (2): 33 32
col 1; TERM
row#10[1909] dba: 4276772=0x414224
col 0; len 1; (1): 34
col 1; TERM
row#11[1765] dba: 4276791=0x414237
col 0; len 2; (2): 34 31
col 1; TERM
row#12[1845] dba: 4276781=0x41422d
col 0; len 2; (2): 34 32
col 1; TERM
row#13[1853] dba: 4276780=0x41422c
col 0; len 1; (1): 35
col 1; TERM
row#14[1773] dba: 4276790=0x414236
col 0; len 2; (2): 35 31
col 1; TERM
row#15[1860] dba: 4276779=0x41422b
col 0; len 1; (1): 36
col 1; TERM
row#16[1781] dba: 4276789=0x414235
col 0; len 2; (2): 36 31
col 1; TERM
row#17[1867] dba: 4276778=0x41422a
col 0; len 1; (1): 37
col 1; TERM
row#18[1789] dba: 4276788=0x414234
col 0; len 2; (2): 37 31
col 1; TERM
row#19[1874] dba: 4276777=0x414229
col 0; len 1; (1): 38
col 1; TERM
row#20[1797] dba: 4276787=0x414233
col 0; len 2; (2): 38 31
col 1; TERM
row#21[1881] dba: 4276776=0x414228
col 0; len 1; (1): 39
col 1; TERM
row#22[1805] dba: 4276786=0x414232
col 0; len 2; (2): 39 31
col 1; TERM
----- end of branch block dump -----
End dump data blocks tsn: 0 file#: 1 minblk 82466 maxblk 82466
发现0好像都省略掉了(0的ASC码为30)
所以想用append 1来试试看 |
|