Thursday, 24 October 2013

Proper usage of Oracle Indexes


Reverse key Indexes:
It has been suggested that using reverse-key indexes will speed-up Oracle INSERT statements, especially with an increasing key, like an index on an Oracle sequence (which is used for the primary key of the target table).  For large batch inserts, Oracle reverse key indexes will greatly speed-up data loads because the high-order index key has been reversed. 
Note: An Oracle reverse key index DOES NOT change the functionality of the index, and it's not the same as reversing the index key values.
In general, an Oracle reverse key index relieve data block contention (buffer busy waits) when inserting into any index where the index key is a monotonically increasing value which must be duplicated in the higher-level index nodes.
With the index key reversal, only the lowest-level index node is changed, and not all of the high-order index nodes, resulting in far faster insert speed.  For updates, Oracle updates the index nodes with each update statement.
Depending on the size of your update batch, it's often faster to drop, update and then re-build the index. If you have more than one CPU, you might consider doing a parallel index rebuild for faster speed. It splits-up the full-table scan:

Bitmap Index vs. B-tree Index: Which and When?

Conventional wisdom holds that bitmap indexes are most appropriate for columns having low distinct values--such as GENDER, MARITAL_STATUS, and RELATION. This assumption is not completely accurate, however. In reality, a bitmap index is always advisable for systems in which data is not frequently updated by many concurrent systems.
In fact, a bitmap index on a column with 100-percent unique values (a column candidate for primary key) is as efficient as a B-tree index.


Query to get all Function based Indexes:

SELECT table_name,
  index_name,
  column_expression
FROM DBA_IND_EXPRESSIONS
WHERE TABLE_OWNER IN ( 'SCOTT')
  AND TABLE_NAME = 'EMP'
ORDER BY index_name,
  column_position;


No comments:

Post a Comment