Re: Eliminating unnecessary left joins
Zeugswetter Andreas DCP SD <zeugswettera@spardat.at>
From: "Zeugswetter Andreas ADI SD" <ZeugswetterA@spardat.at>
To: Ottó Havasvölgyi <havasvolgyi.otto@gmail.com>, "Jim Nasby" <decibel@decibel.org>
Cc: <pgsql-hackers@postgresql.org>
Date: 2007-04-12T09:49:21Z
Lists: pgsql-hackers
> Maybe odd, but simpler to optimize this way. > > Your idea would be also a very good optimization, there was > already a discussion about that here: > http://archives.postgresql.org/pgsql-performance/2006-01/msg00 > 151.php, but that time Tom refused it because it was too > expensive and rare. Maybe now he has a different opinion. > However, left join optimization is lot simpler and cheaper, > and can be useful not only for O/R mappers, but for efficient > vertical partitioning as Simon mentioned. For the views use case there is a simple solution without the expensive optimization: If you have a PK FK relationship simply rewrite the view to use a left join instead of a join. Since there is always one row on the outer (PK) side it makes no difference to the result set. And then the left join optimization can be used. Andreas