Re: Eliminating unnecessary left joins

From: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Ottó Havasvölgyi <havasvolgyi(dot)otto(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Eliminating unnecessary left joins
Date: 2007-04-07 02:00:29
Message-ID: 4616FB3D.6000000@pse-consulting.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> "=?ISO-8859-1?Q?Ott=F3_Havasv=F6lgyi?=" <havasvolgyi(dot)otto(at)gmail(dot)com> writes:
>
>> When using views built with left joins, and then querying against these
>> views, there are a lot of join in the plan that are not necessary, because I
>> don't select/use any column of each table in the views every time. Tables
>> that are left joined and never referenced anywhere else in the query should
>> be removed from the plan.
>>
>
> That might cause you to get the wrong number of copies of some rows ---
> what if a row of the left table should join to multiple rows on the right?
>
That would be trouble. But I've seen quite some cases where the right
can contain only zero or one row, because of PK constraints. In this
case, elimination would be safe.

Regards,
Andreas

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2007-04-07 02:17:29 Re: [HACKERS] [Fwd: Index Advisor]
Previous Message Tom Lane 2007-04-07 01:08:34 Re: Problems with the varlena patch in my module