Re: rewrite in to exists?

From: Manfred Koizar <mkoi-pg(at)aon(dot)at>
To: LN Cisneros <chulat(at)mail(dot)com>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, LN Cisneros <chulat(at)mail(dot)com>, LN Cisneros <lnsea(at)earthlink(dot)net>, Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, LN Cisneros <chulat(at)mail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: rewrite in to exists?
Date: 2003-09-19 08:57:10
Message-ID: 6eglmvc6h739mvth5qjueqsv9363n2c494@email.aon.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Thu, 18 Sep 2003 12:27:23 -0700 (GMT-07:00), LN Cisneros
<lnsea(at)earthlink(dot)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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Matt Clark 2003-09-19 10:41:55 Re: osdl-dbt3 run results - puzzled by the execution
Previous Message Tom Lane 2003-09-19 03:20:37 Re: osdl-dbt3 run results - puzzled by the execution plans