Re: Slow left outer join - Mailing list pgsql-general

From Alexander Staubo
Subject Re: Slow left outer join
Date
Msg-id E42CBF48-B44F-48C4-8746-1BD10F359E39@purefiction.net
Whole thread Raw
In response to Re: Slow left outer join  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Nov 27, 2006, at 02:45 , Tom Lane wrote:

> Alexander Staubo <alex@purefiction.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.


pgsql-general by date:

Previous
From: Alban Hertroys
Date:
Subject: Re: indexes
Next
From: Alban Hertroys
Date:
Subject: Re: Extract between year *and* month