Saturday, August 4, 2012

Today I learnt something new in SQL Queries.. 
Thot I could share with you ppl!

I was running 
query a (select col1 from table1)>> execution time 3 secs
query b (select col1 from table2)>> execution time 5 secs
query a intersect query b 
(select col1 from table1 intersect select col1 from table2)>> execution time 16 mins!

Lot of technicalities and reasons are there for this behavior... but quick fix is as follows
select col1 from table1 where rownum>0
select col1 from table2 where rownum>0 >> execution time 6 secs!