Link to home
Start Free TrialLog in
Avatar of CalDude
CalDudeFlag for United States of America

asked on

Insert into self, pause new indexing, then reindex. Oracle 9i

I would like to know if the following is possible.  I can thing of ways around this, using multiple tables, but I would like to avoid it...

1.  Create Table X
2.  Bulk insert into table X from table Y
3.  Index table X
4.  Pause the indexing of newly inserted rows to table x
5.  Insert into table X from table X
6.  Reindex Table X  (either all or newly added rows, don't care)

The point of #4 is to pause the indexing of the rows being inserted, but not drop the index as it will be useful when reading rows in #5.
Avatar of Sean Stuber
Sean Stuber

you can't "pause" indexing.

You can drop the index before loading, then recreate the index afterward
For bulk loads, this is recommended practice.


Howerver "bulk" is somewhat subjective.
We use dropping the index(s) and after that we rebuild it. Indexes work on the whole table, not on part of them. Index either exist or do not exist.
So you can create index when you need it and drop you to avoid the delay.

The only thing you missed is that only creating index is not enough to use it appropriatelly. It will be ignored by the Optimizer until you collect the statistics over the table and the index (espececially because you are speaking about bulk insert that changes the number of the rows, histograms and depth of the index tree).
ASKER CERTIFIED SOLUTION
Avatar of awking00
awking00
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial