Re: Poor Performance with Distinct Subqueries with EXISTS and EXCEPT - Mailing list pgsql-general

From Tom Lane
Subject Re: Poor Performance with Distinct Subqueries with EXISTS and EXCEPT
Date
Msg-id 8600.1102004805@sss.pgh.pa.us
Whole thread Raw
In response to Re: Poor Performance with Distinct Subqueries with EXISTS and EXCEPT  (Pierre-Frédéric Caillaud<lists@boutiquenumerique.com>)
Responses Re: Poor Performance with Distinct Subqueries with EXISTS and EXCEPT  (Thomas F.O'Connell <tfo@sitening.com>)
List pgsql-general
=?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= <lists@boutiquenumerique.com> writes:
>     I may be mistaken, but you may be doing the same thing twice : you're
> basically writing :

>     SELECT DISTINCT X WHERE Y EXCEPT SELECT DISTINCT X WHERE NOT Y
>     Is this not a way to get an empty result set ?

No, because some X values may appear in rows where Y, and also in rows
where NOT Y.

The DISTINCTs are wastes of time, though, because EXCEPT implies
elimination of duplicates.

            regards, tom lane

pgsql-general by date:

Previous
From: "Magnus Hagander"
Date:
Subject: Re: Pl/Perl w/ Postgres 8.0 on Windows
Next
From: Thomas F.O'Connell
Date:
Subject: Re: Poor Performance with Distinct Subqueries with EXISTS and EXCEPT