pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Stephan Szabo <sszabo@megazone23.bigpanda.com>
Cc: David Olbersen <dave@slickness.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: Optimization via explicit JOINs
Date: Fri, 09 Mar 2001 22:03:10 -0500
Message-ID: <13416.984193390@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.BSF.4.21.0103091817560.82859-100000@megazone23.bigpanda.com>
References: <Pine.BSF.4.21.0103091817560.82859-100000@megazone23.bigpanda.com>

Stephan Szabo <sszabo@megazone23.bigpanda.com> writes:
> Actually, just thought of something else.  If you remove
> the probably redundant p.song_id=s.song_id from the second 
> query (since the join ... using should do that) does it
> change the explain output?

I was just about to point that out.  The WHERE clause *is* redundant
with the JOIN ... USING clause, but the planner will not recognize that,
and accordingly will multiply the estimated selectivity of the two
clauses together.  So the output row count for the JOIN form is
misleadingly small.  If you remove the redundant WHERE clause then you
should get identical planning estimates for both forms of the query.

The planner does actually recognize and discard duplicate qualifiers
that appear in the same place (eg, WHERE p.song_id=s.song_id AND
p.song_id=s.song_id) but it's not so smart about qualifiers that are
in different parts of the query...

			regards, tom lane



view thread (10+ messages)

Message-ID: <13416.984193390@sss.pgh.pa.us>
Permalink:  ../13416.984193390@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/13416.984193390@sss.pgh.pa.us

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, sszabo@megazone23.bigpanda.com, dave@slickness.org
  Subject: Re: Optimization via explicit JOINs
  In-Reply-To: <13416.984193390@sss.pgh.pa.us>
  References: <Pine.BSF.4.21.0103091817560.82859-100000@megazone23.bigpanda.com> <13416.984193390@sss.pgh.pa.us>

* 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