문제

I'm running often this query and I would like to optimize it.

select
    number || ' ' || name
from tasks
where upper(number || ' ' || name) like '%VALUE%'

I've created an index, but the it took the same time as without the index

create index name on tasks (upper(number || ' ' || name))

Are there any other options ?

도움이 되었습니까?

해결책

다른 팁

If you're sure that the condition is selective enough to justify using an index then you might like to try promoting an index fast full scan with the following:

select /*+ INDEX_FFS(tasks your_index_name) */
       number || ' ' || name
from   tasks
where  upper(number || ' ' || name) like '%VALUE%'

Edit:

I seem to recall that another way of promoting an IFFS is:

select number || ' ' || name
from   tasks
where  rowid in (
         select rowid
         from   tasks
         where  upper(number || ' ' || name) like '%VALUE%')

Surprisingly barely less efficient that the former method.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top