Re: improving a badly optimized query - Mailing list pgsql-general

From Tom Lane
Subject Re: improving a badly optimized query
Date
Msg-id 24969.1037982853@sss.pgh.pa.us
Whole thread Raw
In response to Re: improving a badly optimized query  (Brandon Craig Rhodes <brandon@oit.gatech.edu>)
List pgsql-general
Brandon Craig Rhodes <brandon@oit.gatech.edu> writes:
> Tom Lane <tgl@sss.pgh.pa.us> writes:
>> It seems like a useful optimization, but I have an uncomfortable
>> feeling that there's something wrong with it.  Can you point to a
>> rigorous proof that this is okay in complicated contexts such as
>> nested outer joins?

> We can optimize the above query simply by observing that the result of
> a LEFT JOIN includes both the rows that would have been produced by a
> simple JOIN, and those rows of the left table that did not match any
> from the right. [snip]

You didn't answer my question: when there are *nested* outer joins, how
does this transformation apply?  Can a clause from WHERE or an
upper-level JOIN/ON clause be pushed down past one outer join and into
another?

            regards, tom lane

pgsql-general by date:

Previous
From: "scott.marlowe"
Date:
Subject: Re: Lack of use of indexes
Next
From: Don Isgitt
Date:
Subject: Re: Lack of use of indexes