Re: do unneeded outer joins cost? - Mailing list pgsql-sql

From Tom Lane
Subject Re: do unneeded outer joins cost?
Date
Msg-id 4694.1244215537@sss.pgh.pa.us
Whole thread Raw
In response to do unneeded outer joins cost?  (chester c young <chestercyoung@yahoo.com>)
List pgsql-sql
chester c young <chestercyoung@yahoo.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
joint2 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


pgsql-sql by date:

Previous
From: Gianvito Pio
Date:
Subject: Re: Type inheritance
Next
From: Rob Sargent
Date:
Subject: Re: Type inheritance