Re: Understanding INNER JOIN versus IN subquery

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Robert James <srobertjames(at)gmail(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Understanding INNER JOIN versus IN subquery
Date: 2009-07-20 14:21:54
Message-ID: 407d949e0907200721o6abdbebbxc0a1b330019be96f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Jul 20, 2009 at 2:37 PM, Robert James<srobertjames(at)gmail(dot)com> wrote:
> I have two queries which should be equivalent.  The Planner plans them
> differently, although they are both about the same time.  Can someone
> explain why?

Uhm, please post the two plans and the server version. I know you've
posted them before but that was in another thread that I don't have
handy.

The short answer is that the server doesn't know that the subquery is
definitely going to produce distinct results so it doesn't know the
inner join won't produce duplicates. So it can't tell that these
queries might be equivalent.

--
greg
http://mit.edu/~gsstark/resume.pdf

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Grzegorz Jaśkiewicz 2009-07-20 14:28:34 Re: Understanding INNER JOIN versus IN subquery
Previous Message Greg Stark 2009-07-20 14:13:10 Re: Understanding sequential versus index scans.