转自http://www.itpub.net/viewthread.php?tid=1128100
Index block split
1. Block split
1.1 50-50 split
Root block, branch block are always in 50-50 split when the block is full.
If the new value of index is not maximum value of the index, the leaf block is in 50-50 split when the block is full
1.2 90-10 split
If the new value of index is maximum value of the index, the leaf block is in 90-10 split when the block is full
Below is the test case:
drop table split_90_a purge;
create table split_90_a (id number, value varchar2(10));
create index SPLIT_90_A_IDX on split_90_a(id);
begin
for i in 1..540 loop
insert into split_90_a values (i, 'Bowie');
end loop;
commit;
end;
/
1. Insert maximum value of the index, the current index block is plit in 90-10
1.1 insert 540 rows and the index is full now
alter session set events 'immediate trace name treedump level 51323';
----- begin tree dump
leaf: 0x100057c 16778620 (0: nrow: 540 rrow: 540)
----- end tree dump
1.2 insert maximum value
insert into split_90_a values (541, 'Bowie');
commit;
----- begin tree dump
branch: 0x100057c 16778620 (0: nrow: 2, level: 1)
leaf: 0x100057f 16778623 (-1: nrow: 540 rrow: 540)
leaf: 0x1000580 16778624 (0: nrow: 1 rrow: 1)
----- end tree dump
1.3 from the dump content, the first leaf block has 540 rows, the second leaf block has 1 row. It proves that the index is plit in 90-10 rule.
1.4 check statistics, the leaf node 90-10 splits increase 1
select * from v$sysstat where name like '%split%';
before:
STATISTIC# NAME CLASS VALUE STAT_ID
---------- ---------------------------------------------------------------- ---------- ---------- ----------
262 leaf node splits 128 36 1417124053
263 leaf node 90-10 splits 128 27 1285138251
264 branch node splits 128 0 399027615
after:
STATISTIC# NAME CLASS VALUE STAT_ID
---------- ---------------------------------------------------------------- ---------- ---------- ----------
262 leaf node splits 128 37 1417124053
263 leaf node 90-10 splits 128 28 1285138251
264 branch node splits 128 0 399027615
2. Insert middle value of the index, the current index block is plit in 50-50
2.1 insert 540 rows and the index is full now
alter session set events 'immediate trace name treedump level 51323';
----- begin tree dump
leaf: 0x100057c 16778620 (0: nrow: 540 rrow: 540)
----- end tree dump
2.2 insert middle value
insert into split_90_a values (253, 'Bowie');
commit;
----- begin tree dump
branch: 0x100057c 16778620 (0: nrow: 2, level: 1)
leaf: 0x100057f 16778623 (-1: nrow: 279 rrow: 279)
leaf: 0x1000580 16778624 (0: nrow: 262 rrow: 262)
----- end tree dump
2.3 from the dump content, the first leaf block has 279 rows, the second leaf block has 262 row. It proves that the index is plit in 50-50 rule.
2.4 check statistics, the leaf node splits increase 1, but leaf node 90-10 splits does not increase
STATISTIC# NAME CLASS VALUE STAT_ID
---------- ---------------------------------------------------------------- ---------- ---------- ----------
262 leaf node splits 128 38 1417124053
263 leaf node 90-10 splits 128 28 1285138251
264 branch node splits 128 0 399027615
3. Insert 532 value of the index, the current index block is plit in 50-50
3.1 insert 540 rows and the index is full now
alter session set events 'immediate trace name treedump level 51323';
----- begin tree dump
leaf: 0x100057c 16778620 (0: nrow: 540 rrow: 540)
----- end tree dump
3.2 insert middle value
insert into split_90_a values (532, 'Bowie');
commit;
----- begin tree dump
branch: 0x100057c 16778620 (0: nrow: 2, level: 1)
leaf: 0x100057f 16778623 (-1: nrow: 279 rrow: 279)
leaf: 0x1000580 16778624 (0: nrow: 262 rrow: 262)
----- end tree dump
3.3 from the dump content, the first leaf block has 279 rows, the second leaf block has 262 row. It proves that the index is plit in 50-50 rule.
3.4 check statistics, the leaf node splits increase 1, but leaf node 90-10 splits does not increase
STATISTIC# NAME CLASS VALUE STAT_ID
---------- ---------------------------------------------------------------- ---------- ---------- ----------
262 leaf node splits 128 39 1417124053
263 leaf node 90-10 splits 128 28 1285138251
264 branch node splits 128 0 399027615
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/386081/viewspace-606372/
,如需转载,请注明出处,否则将追究法律责任。