Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: index rebuilding...
"DA Morgan" <damorgan_at_exesolutions.com> wrote in message
news:3E3D977E.D31B2DA0_at_exesolutions.com...
> > Sounds to me like someone is going to be doing some block dumps pretty > soon. > > Or at least I hope so. It would be great to have a definitive answer. >
Hi Daniel,
So long as one follows the basic principles that once a leaf node is full, it needs to "split" and by doing so the branch node that points to it requires a new entry and if it's full, it needs to split etc., this will show how Oracle puts it all together.
OK, firstly, lets build a simple table and associated index:
SQL> create table bowie_stuff (id number, album_title varchar(30));
Table created.
SQL> create index bowie_stuff_idx on bowie_stuff(album_title);
Index created.
Now let's populate with some data and get the index structure building along. Note the values I'm using, they'll come in handy later.
SQL> insert into bowie_stuff values (1, 'David Bowie');
1 row created.
SQL> insert into bowie_stuff values (2, 'The Man Who Sold The World');
1 row created.
SQL> insert into bowie_stuff values (3, 'Hunky Dory');
1 row created.
SQL> insert into bowie_stuff values (4, 'Ziggy Stardust');
1 row created.
SQL> insert into bowie_stuff values (5, 'Aladdin Sane');
1 row created.
SQL> insert into bowie_stuff values (6, 'Pin Ups');
1 row created.
SQL> insert into bowie_stuff values (7, 'Diamond Dogs');
1 row created.
SQL> insert into bowie_stuff values (8, 'Young Americans');
1 row created.
SQL> insert into bowie_stuff values (9, 'Station To Station');
1 row created.
SQL> insert into bowie_stuff values (10, 'Low');
1 row created.
SQL> commit;
Commit complete.
SQL> insert into bowie_stuff select * from bowie_stuff;
10 rows created.
SQL> / 20 rows created.
SQL> / 40 rows created.
SQL> / 80 rows created.
SQL> / 160 rows created.
SQL> / 320 rows created.
SQL> commit;
Commit complete.
Having played with this table structure for many years now, I know I'm close to having a "full" index structure. Let's see the current state of affairs:
SQL> analyze index bowie_stuff_idx validate structure;
Index analyzed.
SQL> select height, lf_blks, br_blks from index_stats;
HEIGHT LF_BLKS BR_BLKS
---------- ---------- ----------
2 2 1
We currently have a nice simple index structure with one branch (root) node pointing to two leaf nodes.
I now check to see which blocks I need to dump.
SQL> select file_id, block_id, blocks from dba_extents where segment_name =
'BOW
IE_STUFF_IDX';
FILE_ID BLOCK_ID BLOCKS
---------- ---------- ----------
9 1513 8
What I'll do now is take a before and after dump of the branch and leaf node block while inserting a new row. For the record, three further inserts did the trick and caused the first leaf node to "split".
SQL> insert into bowie_stuff values (7, 'Diamond Dogs');
1 row created.
SQL> commit;
Commit complete.
So now I've "captured" what Oracle has done in order to maintain it's index structure after a node split.
First of all, lets look at an extract of the branch node, just *before* the leaf node split. My comments are preceded with a *** :
Start dump data blocks tsn: 9 file#: 9 minblk 1516 maxblk 1516
buffer tsn: 9 rdba: 0x024005ec (9/1516)
scn: 0x0000.01974320 seq: 0x02 flg: 0x02 tail: 0x43200602
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump: 0x024005ec
Object id on Block? Y
seg/obj: 0x79ab csc: 0x00.197431c itc: 1 flg: E typ: 2 - INDEX brn: 0 bdba: 0x24005e9 ver: 0x01 inc: 0 exflg: 0
Itl Xid Uba Flag Lck Scn/Fsc0x01 0x0001.00b.00006e99 0x00800888.02ca.01 -BU- 1 fsc 0x0000.01974320
Branch block dump
row#0[8041] dba: 37750256=0x24005f0 *** This therefore marks the pointer
to the second leaf node in the index, all values greater than or equal to
col 0 belong in this leaf node. As there are only currently 2 leaf nodes in
this index, that's about it for now ***
col 0; len 7; (7): 50 69 6e 20 55 70 73 *** values greater than or equal
to PIN UPS go here ***
col 1; len 6; (6): 02 40 05 e8 00 eb
----- end of branch block dump -----
End dump data blocks tsn: 9 file#: 9 minblk 1516 maxblk 1516
Next, let's look at the poor index block in "desperate need of a bucket", ie. she's about to blow (split) ;)
Start dump data blocks tsn: 9 file#: 9 minblk 1519 maxblk 1519
buffer tsn: 9 rdba: 0x024005ef (9/1519)
scn: 0x0000.01975306 seq: 0x01 flg: 0x02 tail: 0x53060601
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump: 0x024005ef
Object id on Block? Y
seg/obj: 0x79ab csc: 0x00.1975305 itc: 2 flg: E typ: 2 - INDEX brn: 0 bdba: 0x24005e9 ver: 0x01 inc: 0 exflg: 0
Itl Xid Uba Flag Lck Scn/Fsc0x01 0x0001.02c.00006e97 0x00800489.02cb.04 C--- 0 scn 0x0000.01974321
Leaf block dump
. . <snip> . row#374[841] flag: -----, lock: 0 col 0; len 7; (7): 50 69 6e 20 55 70 73col 1; len 6; (6): 02 40 05 e8 00 d7
Now let's see how Oracle has "documented" the additional leaf node in the branch node:
Start dump data blocks tsn: 9 file#: 9 minblk 1516 maxblk 1516
buffer tsn: 9 rdba: 0x024005ec (9/1516)
scn: 0x0000.01975359 seq: 0x01 flg: 0x02 tail: 0x53590601
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump: 0x024005ec
Object id on Block? Y
seg/obj: 0x79ab csc: 0x00.1975358 itc: 1 flg: E typ: 2 - INDEX brn: 0 bdba: 0x24005e9 ver: 0x01 inc: 0 exflg: 0 Itl Xid Uba Flag Lck Scn/Fsc0x01 0x0004.01e.00006ed7 0x00800a31.024b.03 --U- 1 fsc 0x0000.01975359
Branch block dump
So Oracle has simply added in an appropriate pointer for the new leaf node and values from which are to go into it.
Let's see how our poor "splitted" leaf node looks like:
Start dump data blocks tsn: 9 file#: 9 minblk 1519 maxblk 1519
buffer tsn: 9 rdba: 0x024005ef (9/1519)
scn: 0x0000.0197535a seq: 0x01 flg: 0x02 tail: 0x535a0601
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump: 0x024005ef
Object id on Block? Y
seg/obj: 0x79ab csc: 0x00.1975359 itc: 2 flg: E typ: 2 - INDEX brn: 0 bdba: 0x24005e9 ver: 0x01 inc: 0 exflg: 0 Itl Xid Uba Flag Lck Scn/Fsc0x01 0x0004.01e.00006ed7 0x00800a30.024b.01 CB-- 0 scn 0x0000.01975359
Leaf block dump
. . <snip> .
And finally, an extract of the new leaf node dump and how it "slots" into the index structure:
Start dump data blocks tsn: 9 file#: 9 minblk 1517 maxblk 1517
buffer tsn: 9 rdba: 0x024005ed (9/1517)
scn: 0x0000.0197535b seq: 0x01 flg: 0x00 tail: 0x535b0601
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump: 0x024005ed
Object id on Block? Y
seg/obj: 0x79ab csc: 0x00.197535b itc: 2 flg: E typ: 2 - INDEX brn: 0 bdba: 0x24005e9 ver: 0x01 inc: 0 exflg: 0
Itl Xid Uba Flag Lck Scn/Fsc0x01 0x0004.01e.00006ed7 0x00800a31.024b.01 CB-- 0 scn 0x0000.01975359
Leaf block dump
. . <snip> .
So what does all this show ?
Well hopefully anyone that may have been a bit unsure how indexes hang together, especially when a block split occurs, will be a bit more cluey on what's going on.
Cheers
Richard Received on Mon Feb 03 2003 - 07:54:55 CST
![]() |
![]() |