By default, Oracle uses indexes created.
When I go to NLS_COMP = Linguistic and NLS_Sort = Binary_CI, I get a full table scan.
I read somewhere creating an index using (nlssort (name, 'NLS_SORT = BINARY_CI')); It should work.
As my attempt below shows, not so much. Even if I force it, the performance does not seem to be what I would expect. This is a trivial example that I like to solve for a table with many millions of rows, so a full table scan would be bad.
So the question is how to create indexes so that they are used.
thanks
- X setting
create table x ( name varchar2(30)) ;
insert into x select table_name from all_tables;
create index x_ix on x (name);
create index x_ic on x (nlssort(name, 'NLS_SORT=BINARY_CI'));
/
- Default settings
ALTER SESSION SET NLS_COMP=BINARY;
ALTER SESSION SET NLS_SORT=BINARY;
/
set autotrace on
/
select * from X where NAME like 'x%';
/
set autotrace off
/
- Linguistic
ALTER SESSION SET NLS_COMP=LINGUISTIC;
ALTER SESSION SET NLS_SORT=BINARY_CI;
/
set autotrace on
/
select * from X where NAME like 'x%';
select * from X where NAME like 'x%';
select * from X where NAME like 'x%';
/
set autotrace off
/
Brian_Sullivan