From: | "Prachi Jain" <prachijain3(at)rediffmail(dot)com> |
---|---|
To: | christoph(dot)dalitz(at)hs-niederrhein(dot)de, pgsql-general(at)postgresql(dot)org, shridhar_daithankar(at)persistent(dot)co(dot)in, tgl(at)sss(dot)pgh(dot)pa(dot)us |
Subject: | IN or EXISTS?? faster one |
Date: | 2002-12-19 13:09:47 |
Message-ID: | 20021219130947.8489.qmail@webmail28.rediffmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello All,
I am using too many subqueries in my queries. I have read some
FAQs that using EXISTS is faster than IN. Is that correct?? I
tried to get the total runtime using EXPLAIN ANALYZE, but i got
total runtime for the query with IN but not for the query with
EXISTS.
query with IN:
EXPLAIN ANALYZE Select * from bom where depot_id in ( SELECT
depot_id from depot where company_name ='SOME' );
query with EXISTS:
EXPLAIN ANALYZE Select * from bom WHERE EXISTS ( SELECT depot_id
from depot where company_name ='SOME' and depot.depot_id =
bom.depot_id );
I read the same for using with select count(*)...is too slow. How
to replace for that??
Moreover, what are the other things one should take care of
regarding reducing the time taken by the queries??
Thanks in advance.
Regards
Prachi
From | Date | Subject | |
---|---|---|---|
Next Message | S Dawalt | 2002-12-19 14:01:32 | Re: trouble caused by change in 7.3 handling of '' in |
Previous Message | Lee Kindness | 2002-12-19 09:46:25 | trouble caused by change in 7.3 handling of '' in integer context |