Re: Joins and their efficiencies

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hadley Willan <hadley(dot)willan(at)deeperdesign(dot)co(dot)nz>
Cc: Postgresql General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Joins and their efficiencies
Date: 2003-04-02 21:16:55
Message-ID: 23233.1049318215@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hadley Willan <hadley(dot)willan(at)deeperdesign(dot)co(dot)nz> writes:
> Is it correct then to assume that a LEFT JOIN is more efficient than a
> straight join?

Not at all. I would imagine that the left join forced the planner to
adopt a different plan than it used otherwise (perhaps a different join
order), and that this other plan was much faster than the original,
whereas the planner's estimate had it slower (else it would have used
that plan to begin with).

It could also be that the change in the WHERE clauses had something to
do with it.

If you want to investigate further, make sure your ANALYZE stats are up
to date, then post EXPLAIN ANALYZE results for both queries.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message alex b. 2003-04-02 21:23:02 images in database
Previous Message Tom Lane 2003-04-02 20:59:36 Re: Backend often crashing