Eliminating unnecessary left joins

From: Ottó Havasvölgyi <havasvolgyi(dot)otto(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Eliminating unnecessary left joins
Date: 2007-04-06 22:01:30
Message-ID: 34608c0c0704061501lb632332l22fa471f118ddea3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

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. I think this can be done without any other
analyzation or catalog lookup, so it is a quite cheap optimization step, and
doing it won't influence the result, but the query will run faster.
This way with a complex query against these views usually the half of the
join can be eliminated, and the plan will be quite more optimal.
Why left join a table if never used/referenced in the query?

How easy is to teach Postgres to this?

I would like to help somehow to introduce this feature as soon as possible.
What should I do?

Thanks,
Otto

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2007-04-06 23:00:53 Re: [PATCHES] Fix for large file support
Previous Message Zdenek Kotala 2007-04-06 21:29:55 Re: [PATCHES] Fix for large file support