pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
do unneeded outer joins cost?
2+ messages / 2 participants
[nested] [flat]

* do unneeded outer joins cost?
@ 2009-06-05 15:01  chester c young <chestercyoung@yahoo.com>
  0 siblings, 1 reply; 2+ messages in thread

From: chester c young @ 2009-06-05 15:01 UTC (permalink / raw)
  To: pgsql-sql


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?

(the question goes as to how much generated sql needs to be cleaned to be efficient)



      



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: do unneeded outer joins cost?
@ 2009-06-05 15:25  Tom Lane <tgl@sss.pgh.pa.us>
  parent: chester c young <chestercyoung@yahoo.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2009-06-05 15:25 UTC (permalink / raw)
  To: chester c young <chestercyoung@yahoo.com>; +Cc: 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 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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2009-06-05 15:25 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-06-05 15:01 do unneeded outer joins cost? chester c young <chestercyoung@yahoo.com>
2009-06-05 15:25 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox