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