Re: Slow left outer join

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alexander Staubo <alex(at)purefiction(dot)net>
Cc: PgSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Slow left outer join
Date: 2006-11-27 01:45:48
Message-ID: 963.1164591948@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alexander Staubo <alex(at)purefiction(dot)net> writes:
> select comments.*, users.*
> from comments
> left outer join users on
> users.id = comments.creator_id
> inner join events_comments on
> comments.id = events_comments.comment_id
> and events_comments.event_id = 9244

> The outer join seems unnecessarily slow.

Try flipping the order of the two joins. PG 8.2 will be smart enough to
do that for itself, but no existing release understands when it's safe
to rearrange outer-join order.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jim Nasby 2006-11-27 01:55:55 Re: Question about PG cache selection strategy
Previous Message Richard Broersma Jr 2006-11-27 01:40:37 Re: Slow left outer join