Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

LINGUISTIC index not being used when it should be - why?

610745Mar 18 2008 — edited Mar 19 2008
We have Oracle 10g R2 and using the case insensitve feature within the database. We have 2 schemas, one called 'app' and the other 'crs'. The crs schema owns the all the tables, views etc and has granted select on its objects to schema app.

We have a 'after log on' trigger on schema app the executes the following:
execute immediate 'alter session set NLS_COMP=LINGUISTIC';
execute immediate 'alter session set NLS_SORT=BINARY_CI';

We have a people table containing 180,000 records defined as:
person_id varchar2(10) not null and primary key,
.....
surname varchar2(200) not null
....

We have the following indexes on this table:
create index my_indx1 on people (nlssort(person_id, 'NLS_SORT=BINARY_CI'));

create index my_indx2 on people (nlssort(surname, 'NLS_SORT=BINARY_CI'));

create index my_indx3 on people (upper(surname));

So, when I run the following SQL as schema CRS:
select * from people where upper(surname) = 'xxxxxx'
it uses my_indx3 which is what I expect.

But when I run the same sql as schema app it does a full table scan when I expected it to use my_indx2. Why isn't it using my_indx2 - what am I missing here - do I need to include a hint into the sql?????

Cheers
John.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 16 2008
Added on Mar 18 2008
3 comments
410 views