Re: - Mailing list pgsql-sql

From Haller Christoph
Subject Re:
Date
Msg-id 200109071313.PAA12669@rodos
Whole thread Raw
In response to  ("postgresql" <pgsql@symcom.com>)
List pgsql-sql
My understanding is you did it the best way. 
Alternatively, you may word your query as 
SELECT i.cname FROM fc_client_info i 
WHERE EXISTS ( SELECT * FROM fc_communication c               WHERE c.acode = i.acode        AND c.contactdate =
'09/06/2001')
 
ORDER BY lower(i.cname);
instead of 
SELECT i.cname FROM fc_client_info i, fc_communication c WHERE i.acode =
c.acode AND c.contactdate = '09/06/2001' ORDER BY lower(cname);

I suppose the correlated subquery using the EXISTS predicate, which 
results in an outer loop join, is much slower than your originally 
used sort-merge join. 
Try, but make sure both tables are well populated, otherwise the 
benchmark result is no good. 
Christoph 


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: duplicated oid
Next
From: Haller Christoph
Date:
Subject: ERROR: DefineQueryRewrite: rule plan string too big.