-
CREATE INDEX vs. ALTER INDEX REBUILD
Can anybody point me to some documentation about what goes on during a CREATE INDEX and a ALTER INDEX REBUILD? I am trying to figure out if ALTER INDEX REBUILD reads the old index to create the "rebuilt" index, or if the REBUILD goes back to the table to create the "rebuilt" index. I have an idea, but I need definitive proof.
For example, if I have a table (XYZ) that has 1 million rows and an index (XYZ_PK) that is a unique index on that table. If I issue CREATE UNIQUE INDEX xyz_pk ON xyz(x) of course every row in XYZ will be read. However, if I issue ALTER INDEX xyz_pk REBUILD, does Oracle read XYZ_PK and re-organize the blocks or does it read XYZ to build the new index?
Jeff Hunter
-
Use the ALTER INDEX ... REBUILD statement to reorganize or compact an existing index or to change its storage characteristics. The REBUILD statement uses the existing index as the basis for the new one. All index storage statements are supported, such as STORAGE (for extent allocation), TABLESPACE (to move the index to a new tablespace), and INITRANS (to change the initial number of entries).
ALTER INDEX ... REBUILD is usually faster than dropping and re-creating an index, because this statement uses the fast full scan feature. It reads all the index blocks using multiblock I/O then discards the branch blocks. A further advantage of this approach is that the old index is still available for queries while the rebuild is in progress.
http://download-west.oracle.com/docs..._acce.htm#7531
Does that help?
MH
I remember when this place was cool.
-
That would be it! I've been looking at the Concepts and Admin guide for over an hour...
Jeff Hunter
-
When rebuilding a normal index, the statistics for that index are not affected.
SQL> create index x_test on test ( y ) global;
Index created.
SQL> analyze table test compute statistics;
Table analyzed.
SQL> select index_name, leaf_blocks from user_indexes;
INDEX_NAME LEAF_BLOCKS
------------------------------ -----------
X_TEST 3
SQL> alter index X_TEST rebuild;
Index altered.
SQL> select index_name, leaf_blocks from user_indexes;
INDEX_NAME LEAF_BLOCKS
------------------------------ -----------
X_TEST 3
Thus no change to the statistics when the index has been rebuilt.
Last edited by arjun; 02-20-2003 at 01:39 PM.
("`-''-/").___..--''"`-._
`6_ 6 ) `-. ( ).`-.__.`)
(_Y_.)' ._ ) `._ `. ``-..-'
_..`--'_..-_/ /--'_.' ,'
(((' (((-((('' ((((
-
Well, in that case.......ahem...
IT TOOK ME 30 SECONDS TO FIND THIS ON TAHITI, I SUGGEST YOU DO A LITTLE HOMEWORK BEFORE POSTING HERE!!
C'mon, I've been waiting to say that for at least 2 years.
Who do you love?
MH
I remember when this place was cool.
-
-
funky...
"I Dont Want To Follow A Path, I would Rather Go Where There Is No Path And Leave A Trail."
"Ego is the worst thing many have, try to overcome it & you will be the best, if not good, person on this earth"
-
Originally posted by arjun
When rebuilding a normal index, the statistics for that index are not affected.
SQL> create index x_test on test ( y ) global;
Index created.
SQL> analyze table test compute statistics;
Table analyzed.
SQL> select index_name, leaf_blocks from user_indexes;
INDEX_NAME LEAF_BLOCKS
------------------------------ -----------
X_TEST 3
SQL> alter index X_TEST rebuild;
Index altered.
SQL> select index_name, leaf_blocks from user_indexes;
INDEX_NAME LEAF_BLOCKS
------------------------------ -----------
X_TEST 3
Thus no change to the statistics when the index has been rebuilt.
When you rebuild them then you must know why you're rebuilding them.
You want them to stay "compact" as you planned or make them airy so the levels don't increase that fast...and then add pctfree in that clause............
Tarry Singh
I'm a JOLE(JavaOracleLinuxEnthusiast)
--- Everything was meant to be---
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|