Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Case Insensitive Query Performance
The problem is that Oracle isn't able to use an index for a column, if
you use a function in the where clause for this col. With a little
trick, you enable Oracle to use an index to select a relatively small
number of possible reocord and then do a full scan on these small
number.
Try the following statement: (e.g. you want to select records with
surname 'NEWTON')
SELECT ...
FROM xyz
WHERE ( ( surname LIKE 'ne%' ) OR ( surname LIKE 'Ne%' ) OR ( surname LIKE 'NE%' ) OR ( surname like 'nE%' ) )
So with the first part of the query, Oracle can use an index on surname and for the second part it has to scan only a few records, instead of more than 400K. (If the performance is still poor, try all lower/upper combinations of the first three letters of the search criteria)
Hope this helps.
Dean Mah wrote:
> This must be a FAQ....
>
> I have a table with a surname field which is mixed case. I want to do
> a
> case insensitive search against this field. I have used the UPPER
> function to force both the surname and my search criteria to
> uppercase.
> Obviously, this results in poor performance.
>
> I have tried to create an index with UPPER(surname) which didn't work.
>
> I've tried to create a view with UPPER(surname) which didn't work. I
> don't want to create another field with the surname in uppercase
> because
> there are >400K records in the table and it is growing.
>
> Any hints, ideas, solutions, ... would be greatly appreciated.
> Dean
Received on Thu Apr 16 1998 - 16:17:37 CDT