Re: Optimization via explicit JOINs

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: David Olbersen <dave(at)slickness(dot)org>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Optimization via explicit JOINs
Date: 2001-03-10 03:03:10
Message-ID: 13416.984193390@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Najm Hashmi 2001-03-10 16:27:27 from PosgreSQL 7.1b3 to 7.0.3
Previous Message Stephan Szabo 2001-03-10 02:18:47 Re: Optimization via explicit JOINs