Re: rewrite in to exists? - Mailing list pgsql-performance

From Manfred Koizar
Subject Re: rewrite in to exists?
Date
Msg-id 6eglmvc6h739mvth5qjueqsv9363n2c494@email.aon.at
Whole thread Raw
In response to Re: rewrite in to exists?  (LN Cisneros <lnsea@earthlink.net>)
List pgsql-performance
On Thu, 18 Sep 2003 12:27:23 -0700 (GMT-07:00), LN Cisneros
<lnsea@earthlink.net> wrote:
>But, the EXISTS version doesn't

Laurette,
looking at that SELECT statement again I can't see what's wrong with
it.  One of us is missing something ;-)

> really give me what I want...

Can you elaborate?

SELECT code, id, date_of_service
  FROM tbl
 WHERE EXISTS (SELECT *
                 FROM tbl t2
                WHERE t2.xxx >= '29800' AND t2.xxx <= '29909'
                  AND t2.code = 'XX'
                  AND tbl.date_of_service = t2.date_of_service) -- (!)
   AND client_code = 'XX'
 ORDER BY id, date_of_service;

>all rows in tbl that
 ^^^
Well, all that have client_code = 'XX', as in your original query.

> match the date of the subquery.

The matching is done by the line with the (!) comment.

Servus
 Manfred

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: osdl-dbt3 run results - puzzled by the execution plans
Next
From: "Matt Clark"
Date:
Subject: Re: osdl-dbt3 run results - puzzled by the execution