pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Martijn van Oosterhout <kleptog@svana.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org, Andrea Olson <Andrea.Olson@wicourts.gov>
Cc: Bill Severson <Bill.Severson@wicourts.gov>
Cc: John Hutchins <John.Hutchins@wicourts.gov>
Cc: Randy Peterson <Randy.Peterson@wicourts.gov>
Cc: Shannon Spranger <Shannon.Spranger@wicourts.gov>
Subject: Re: EXISTS optimization
Date: Fri, 23 Mar 2007 23:26:41 +0100
Message-ID: <20070323222641.GD9623@svana.org> (raw)
In-Reply-To: <25339.1174686582@sss.pgh.pa.us>
References: <4603C1A3.EE98.0025.0@wicourts.gov>
	<25339.1174686582@sss.pgh.pa.us>

On Fri, Mar 23, 2007 at 05:49:42PM -0400, Tom Lane wrote:
> We don't currently try to flatten EXISTS into a unique/join plan as we
> do for IN.  I seem to recall not doing so when I rewrote IN planning
> because I didn't think it would be exactly semantically equivalent,
> but that was awhile ago.  Right at the moment it seems like it ought
> to be equivalent as long as the comparison operators are strict.

Wasn't it due to the fact that IN needs to scan through all
possibilites anyway because of its interaction with NULL, whereas
EXISTS can stop at the first row?

That would mean the subquery to be materialised would not be equivalent
if it called any non-immutable functions. It's also much less clear to
be a win in the EXISTs case. But then, that's a costs issue the planner
can deal with...

Have a nice day,
-- 
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachments:

  signature.asc (application/pgp-signature, 188B) download

view thread (12+ messages)  latest in thread

Message-ID: <20070323222641.GD9623@svana.org>
Permalink:  ../20070323222641.GD9623@svana.org/
Also on:    postgresql.org/message-id/20070323222641.GD9623@svana.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: kleptog@svana.org, tgl@sss.pgh.pa.us, Kevin.Grittner@wicourts.gov, Andrea.Olson@wicourts.gov, Bill.Severson@wicourts.gov, John.Hutchins@wicourts.gov, Randy.Peterson@wicourts.gov, Shannon.Spranger@wicourts.gov
  Subject: Re: EXISTS optimization
  In-Reply-To: <20070323222641.GD9623@svana.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox