jennyflower
Programmer
Hi, I have a query like this:
select tb1.fd1, tb1.fd2, tb1.fd3, tb2.fd1, tb2.fd2, tb2.fd3 from tb1 join tb2 on tb1.fd1=tb2.fd1 where tb1.fd1 = 1 and (tb1.fd2 = 'P' or tb1.fd2 = 'Q' or tb1.fd2 = 'R') and tb1.fd3 > CURRENT_DATE and tb2.fd1 = 3 and tb2.fd2 <= CURRENT_DATE and tb2.fd3 != NULL order by tb1.fd1
would this type of query be better optimised and probably run faster if i were to split it into 2 subselects like
select tb1.fd1, qrytb1.fd2, qrytb1.fd3, qrytb2.fd1, qrytb2.fd2, qrytb2.fd3
from tb1
join (select * from tb1) as qrytb1 on tb1.fd1=qrytb1.fd1
join (select * from tb2) as qrytb2 on tb1.fd1=qrytb2.fd1
order by tb1.fd1
Hope this makes sese to someone!!
Jen
select tb1.fd1, tb1.fd2, tb1.fd3, tb2.fd1, tb2.fd2, tb2.fd3 from tb1 join tb2 on tb1.fd1=tb2.fd1 where tb1.fd1 = 1 and (tb1.fd2 = 'P' or tb1.fd2 = 'Q' or tb1.fd2 = 'R') and tb1.fd3 > CURRENT_DATE and tb2.fd1 = 3 and tb2.fd2 <= CURRENT_DATE and tb2.fd3 != NULL order by tb1.fd1
would this type of query be better optimised and probably run faster if i were to split it into 2 subselects like
select tb1.fd1, qrytb1.fd2, qrytb1.fd3, qrytb2.fd1, qrytb2.fd2, qrytb2.fd3
from tb1
join (select * from tb1) as qrytb1 on tb1.fd1=qrytb1.fd1
join (select * from tb2) as qrytb2 on tb1.fd1=qrytb2.fd1
order by tb1.fd1
Hope this makes sese to someone!!
Jen