Domanda

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 ?

È stato utile?

Soluzione

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top