Re: Poor Performance with Distinct Subqueries with EXISTS and EXCEPT

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Pierre-Frédéric Caillaud <lists(at)boutiquenumerique(dot)com>
Cc: "Thomas F(dot)O'Connell" <tfo(at)alumni(dot)brown(dot)edu>, "PgSql General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Poor Performance with Distinct Subqueries with EXISTS and EXCEPT
Date: 2004-12-02 16:26:45
Message-ID: 8600.1102004805@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

=?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= <lists(at)boutiquenumerique(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas F.O'Connell 2004-12-02 16:34:27 Re: Poor Performance with Distinct Subqueries with EXISTS and EXCEPT
Previous Message Chris Green 2004-12-02 15:48:14 Re: UNION with ORDER BY -allowed?