Re: IN vs EXISTS equivalence - Mailing list pgsql-hackers

From Gregory Stark
Subject Re: IN vs EXISTS equivalence
Date
Msg-id 87ej4vxp3l.fsf@oxford.xeocode.com
Whole thread Raw
In response to Re: IN vs EXISTS equivalence  (Decibel! <decibel@decibel.org>)
Responses Re: IN vs EXISTS equivalence  (Decibel! <decibel@decibel.org>)
List pgsql-hackers
"Decibel!" <decibel@decibel.org> writes:

> On Aug 8, 2008, at 3:23 PM, Tom Lane wrote:
>> * has no set operations (UNION etc), grouping, set-returning functions
>> in the SELECT list, LIMIT, or a few other funny cases
>
>
> Couldn't union/union all be treated as
>
> EXISTS(a)
> OR EXISTS(b)

Kind of confused by what you mean here. Can you give an example?

The usual transformation to consider with UNION is to transform

SELECT ... WHERE x OR y

into

SELECT ...WHERE x
UNION ALL
SELECT ...WHERE y AND NOT x

(modulo handling NULLs properly)

--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com Ask me about EnterpriseDB's RemoteDBA services!


pgsql-hackers by date:

Previous
From: "Jaime Casanova"
Date:
Subject: Re: Column level privileges was:(Re: Extending grant insert on tables to sequences)
Next
From: Alvaro Herrera
Date:
Subject: Re: autovacuum and TOAST tables