Received: from resy5.fzk.de (resy5.fzk.de [141.52.68.8]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f87DDh781074 for ; Fri, 7 Sep 2001 09:13:43 -0400 (EDT) (envelope-from ch@rodos.fzk.de) Received: by rodos.fzk.de with ESMTP (8.8.6 (PHNE_17135)/8.7.1) id PAA15077 for ; Fri, 7 Sep 2001 15:13:39 +0200 (METDST) From: Haller Christoph Message-Id: <200109071313.PAA12669@rodos> Subject: Re: To: pgsql-sql@postgresql.org Date: Fri, 07 Sep 2001 15:13:38 METDST X-Mailer: Elm [revision: 212.4] X-Archive-Number: 200109/25 X-Sequence-Number: 4671 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