Why using a column of a virtual table makes an SQL in Oracle slow

Asked

Viewed 258 times

3

Good.

Without wanting to leave the subject too "gassy" but wanted only tips of things to investigate in the environment.

I have an SQL that uses a virtual table, for a number of reasons that are not very relevant.

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 test like

 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))

Doing this makes SQL extremely slow.

What could be investigated.

I do not know if details of type description , indexes etc would help, the basic question is :

Why using a column of a virtual table makes an SQL in Oracle slow ?

Grateful.

1 answer

2

If interest to others , I resolved 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))

Source

Browser other questions tagged

You are not signed in. Login or sign up in order to post.