Re: Re: Does PostgreSQL support EXISTS? - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Re: Does PostgreSQL support EXISTS?
Date
Msg-id 20010613195011.A31062@svana.org
Whole thread Raw
In response to Re: Re: Does PostgreSQL support EXISTS?  (Michael Meskes <meskes@postgresql.org>)
List pgsql-general
On Wed, Jun 13, 2001 at 09:21:02AM +0200, Michael Meskes wrote:
> On Wed, Jun 13, 2001 at 12:23:15PM +1000, Martijn van Oosterhout wrote:
> > select x from a where v in (select v from b)
> > select x from a where exists (select 1 from b where a.v = b.v)
>
> The latter should be faster than the former on every relational database
> system.

Huh? Since they do the same thing should they (in theory) run in the same
time.

Now, I can imagine most DBMSs would optimes the latter better than the
forward, but that doesn't change the theory. In theory someone should be
able to program postgres' rule rewrite to rewrite the former to the latter
and then they would execute identically.
--
Martijn van Oosterhout <kleptog@svana.org>
http://svana.org/kleptog/

pgsql-general by date:

Previous
From: Allan Kamau
Date:
Subject: PLPGSQL: Using Transactions and locks
Next
From: Grzegorz Mucha
Date:
Subject: Extracting database metadata