The situation :
-
i have a table A.
-
i want to load a lots of data into table A( lets say few millions records or more )
Ok so i look for options etc., and i came to conclusion that i should disable indexes for the table during loadtime ok :
*alter index your_index unusable;*
But during load other processes and systems can search data in table A and insert data into table A. So i need to use :
*alter system set skip_unusable_indexes = true;*
After data is loaded i rebuild index and clear flags.
Ok here comes a questions :
-
will queries use my index( when it is set unusable ) – we are talking about big tables, without index they will timeout
-
if 1 is true what happens with newly inserted records( i mean the ones inserted through other processes not bulk-load ) before i rebuild index, are they returned when queried? Is it possible to somehow partially rebuild indexes/disable them for one session and keep for other?
I mean it shouldn`t be such uncommon situation in big systems – lots of data to load, but system needs to stay responsive.
To summarize – partitioning and partition exchange looks like the way to go
If the index is unusable, queries will not be able to use it. If your queries will time out if they cannot use the index and the queries need to happen at the same time that you are loading data, you can’t mark the index unusable. You’ll have to incur the overhead of index maintenance during your loads.
Depending on the situation, you may benefit from partitioning the table in such a way that the large loads can be done into a staging table, the index(es) are built on the staging table, and a partition exchange is done to exchange a new, empty partition in the table for the staging table you just populated. Of course, without knowing more about the data, it’s impossible to know whether partitioning the table in this way would be possible or whether it would have other negative implications for query performance.