Question:
Good.
Not wanting to make the subject too "gaseous" but I just wanted tips on things to investigate in the environment.
I have a SQL that uses a virtual table, for a number of reasons that don't really matter.
Something like :
select *
from
(select a,b,c,x,virtual.d
from tabela1,
(select a,b,c,d
from tabela2
where ....) virtual
where virtual.a = tabela1.a
and virtual.b = tabela1.b
virtual.c = tabela1.c)
SQL runs fast , but I need to do a type test
select *
from
(select a,b,c,virtual.d
from tabela1,
(select a,b,c,d
from tabela2
where ....) virtual
where virtual.a = tabela1.a
and virtual.b = tabela1.b
virtual.c = tabela1.c)
where ((c <> d) or (a=1))
By doing this the SQL is extremely slow.
What could be investigated.
I don't know if details like description, indexes etc would help, the basic question is:
Why does using a column from a virtual table make SQL in Oracle slow?
Grateful.
Answer:
If it is of interest to others , I solved it with a HINT
SELECT /*+USE_CONCAT*/ * from
(select a,b,c,virtual.d
from tabela1,
(select a,b,c,d
from tabela2
where ....) virtual
where virtual.a = tabela1.a
and virtual.b = tabela1.b
virtual.c = tabela1.c)
where ((c <> d) or (a=1))