Re: do unneeded outer joins cost?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: chester c young <chestercyoung(at)yahoo(dot)com>
Cc: sql pgsql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: do unneeded outer joins cost?
Date: 2009-06-05 15:25:37
Message-ID: 4694.1244215537@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

chester c young <chestercyoung(at)yahoo(dot)com> writes:
> for example:

> select t1.*
> from t1
> left join t2 on( <expensive condition> );

> since t2 is not used in the result nor is it used in determining the result, is the <expensive condition> to left join t2 used?

It's not correct that the t2 join is irrelevant to the result. If any
row of t1 joins to more than one row of t2 then the join would affect
the result.

In some cases it is possible to prove that no row of t1 can join to more
than one row of t2, in which case the join to t2 could be dropped.
Postgres does not currently implement such an optimization (although
I believe someone is working on it for 8.5). It seems likely though
that an "expensive" join condition would be too complex to be amenable
to such a proof anyway.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Rob Sargent 2009-06-05 16:38:24 Re: Type inheritance
Previous Message Gianvito Pio 2009-06-05 15:13:10 Re: Type inheritance