Re: Slow left outer join

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

On Nov 27, 2006, at 02:45 , Tom Lane wrote:

> 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.

That fixes it. Thanks.

Alexander.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Weerts, Jan 2006-11-27 10:38:38 Re: Connecting via ssh tunnel
Previous Message Alban Hertroys 2006-11-27 09:22:22 Re: Extract between year *and* month