Oct 7, 2013

CHAR Index (vs) NUMERIC Index in Oracle - Index performance

Number Vs character Index in Oracle
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Document on : CHAR Index (vs) NUMERIC Index - Index performance
Applies to : Any Oracle version of any platform
 Scope: Only for OLTP database environments

Indexing on NUMBER data type is faster than indexing on VARCHAR2 data type. Not only Oracle but also other RDBMSs search the index object (indexed on NUMBER datatype) faster than VARCHAR2 datatype. Remember if a sequence number is used on the indexed column, then the index is moving towards one side, and the search takes longer time to find appropriate key values. In the values are entered randomly, then the index on number data type is good.

If an index is created on the CHAR datatype column, then SQL statement must have its full value in the where clause in order to use the index, otherwise index will not be used. For ex, an index is created on NAME CHAR(20) , and you issue a statement like,
SELECT * from emp where name = 'SCOTT';
the index will not be used since query has less than 20 characters in the constant value.

Best use of Index column (In case of OLTP databases):
------------------------------------------------------------------------
Do's:
1) Use Index for numeric columns.
2) Column uniqueness values for indexed column should > 70% for better use.
3) Keep less no. of. indexes for at table if DML operations are more.

Don'ts
1) Do not use index for column of type charcater length 2000 or 4000.
2) Don't use Index for a column if uniqueness for the column if less than 25%.
3) Don't use bit-map index.
4) Avoid to keep composite indexes

Hope this will help to design table structure.
Thanks

No comments:

Post a Comment

Translate >>