SQL Performance (MOSC)

MOSC Banner

Query optimizer doesn't use best index even with INDEX hint.

I am running database 11g version 11.2.0.4. I have a table TRN_Membership with a bunch of fields including two varchar fields named Organization and Last_First. There is a normal index named trn_membership_name_index on organization, last_first.

I would expect the query:

select * from trn_membership where organization='usta' and last_first = 'P'

to use the name_index rather than a full scan and it does, but if I change the query to

select * from trn_membership where organization='usta' and last_first >= 'P'

it switches to a full access scan. I added the hint /*+ INDEX (trn_membership) */ to force the use of an index but it does not change the sql plan. I even was explicit with the hint /*+ INDEX (trn_membership trn_membership_name_index) */ but the optimizer would still not do an index scan.

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center