Re: Propogating conditions into a query

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Phil Endecott <spam_from_postgresql_general(at)chezphil(dot)org>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: Propogating conditions into a query
Date: 2005-06-09 17:17:16
Message-ID: 14403.1118337436@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Phil Endecott <spam_from_postgresql_general(at)chezphil(dot)org> writes:
> I don't see anything in there about LEFT OUTER JOIN though. Any ideas?

Oh, I missed that part of your message. Hmm, I think the issue is that in

>> D join (M join G on (M.g=G.id)) on (D.id=M.b) where D.id=nnn

the planner deduces M.b=nnn by transitivity, but when the join is an
outer join it can't make the same deduction.

[ thinks some more... ] If we distinguished conditions that hold below
the join from those that hold above it, we could deduce that M.b=nnn can
be enforced below the join even though it might not be true above it.
There's no such mechanism in existence now, though.

A possible workaround is to generate your query like

D left join (M join G on (M.g=G.id)) on (D.id=M.b AND M.b=nnn) where D.id=nnn

but I don't know how practical that is for you.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Phil Endecott 2005-06-09 17:34:09 Re: Propogating conditions into a query
Previous Message Phil Endecott 2005-06-09 17:07:51 Re: Propogating conditions into a query