|
|
|
Re: Reverse key index [message #337100 is a reply to message #336895] |
Tue, 29 July 2008 22:03 |
rleishman
Messages: 3728 Registered: October 2005 Location: Melbourne, Australia
|
Senior Member |
|
|
Throw away that book.
Reverse key indexes affect the way the index data is stored; not the way you need to query it.
Oracle is not using the index because it thinks it is better NOT to. Make sure you have gather statistics on the table AND the index with DBMS_STATS.GETHER_TABLE_STATS() then try again.
If it still doesn't work, post the following here:
- Explain Plan
- Number of rows in the tables
- Number of rows with enty_group_code = 'INSURED'
Ross Leishman
|
|
|
|
Re: Reverse key index [message #337407 is a reply to message #337219] |
Wed, 30 July 2008 16:45 |
sunil_v_mishra
Messages: 506 Registered: March 2005
|
Senior Member |
|
|
Limiting conditions placed on the rows correspond to the leading columns of the index, but the conditions use the LIKE operatorand the value starts with '%' or the value is a bind variable. ex. neither of the following will be able to use the index:
WHERE ENTY_LAST_NAME LIKE 'TRIO DEVELOPMENT CORPORA%'
WHERE column LIKE : ABC_BIND_VARIABLE
NOTE: The bind variable may contain trailing '%' or no '%' at all. Regardless, an index will not be used.
|
|
|
|
|
Re: Reverse key index [message #337449 is a reply to message #337219] |
Wed, 30 July 2008 22:52 |
rleishman
Messages: 3728 Registered: October 2005 Location: Melbourne, Australia
|
Senior Member |
|
|
getritesh wrote on Wed, 30 July 2008 18:21 | 2) Total rows in entity_address_master table : 2154650
3) no. of rows satisfying condition "enty_group_code = 'INSURED' " = 937041
|
You are querying half the table. Indexes are only used for returning small portions of the table. Oracle is right to choose a full scan because the index scan would be MUCH slower.
getritesh wrote on Wed, 30 July 2008 18:21 | Select *
From ENTITY_ADDRESS_MASTER
Where ENTY_LAST_NAME LIKE 'TRIO DEVELOPMENT CORPORA%';
I made Reverse key index on column ENTY_LAST_NAME
|
You cannot perform RANGE SCANs on a REVERSE key index. You can only EQUALS and IN. Make the index normal (not reverse) and it will work.
Ross Leishman
|
|
|