I have the following statement:
WITH foos AS (
select regexp_substr('H50','[^,]+', 1, level) x from dual
connect by regexp_substr('H50', '[^,]+', 1, level) is not null
), baars AS (
select regexp_substr('G30','[^,]+', 1, level) x from dual
connect by regexp_substr('G30', '[^,]+', 1, level) is not null
)
select
count(*)
from VIEW
where foo in (
'H50'
-- select x from foos
)
and bar in (
'G30'
-- select x from bars
);
When using the constants G30 and H50 it is really fast. However when I use the subquerys, it is realy slow (~5 seconds).
I have no idea why this can be the case. any ideas?
use constantsanduse subquery?EXPLAIN ANALYZEand some information about table size, index, current time performance, desire time, etc.Slowis a relative term and we need a real value to compare.where foo in ('H50')and notwhere foo ='H50'? Not sure this has something to do with the performance issue you are facing, but still... (the same for the second condition of course).where foo in ('H50')is faster thanwhere foo in (select x from foos)? Check the EXPLAIN PLAN