Re: [SQL] Unnecessary repeat condition for a self inner join

2008-07-12 Thread Tom Lane
"Robins Tharakan" <[EMAIL PROTECTED]> writes: > Besides, I did a simple test and although you are right about the optimizer > deducing implied equality conditions, this holds true only for a direct > join. In the second query, the optimizer recommends a table scan even for a > simple IN() condition

Re: [SQL] Unnecessary repeat condition for a self inner join

2008-07-12 Thread Robins Tharakan
> While the optimizer theoretically could deduce the extra restriction > condition, it doesn't attempt to. It's extremely unclear that the extra > cycles to look for such cases would be repaid on average, because cases > like this aren't that common. The current state of affairs is that > the sys

Re: [SQL] Unnecessary repeat condition for a self inner join

2008-07-11 Thread Tom Lane
"Robins Tharakan" <[EMAIL PROTECTED]> writes: > In case of an INNER JOIN, shouldn't the second condition (in Query2) be > unnecessary ? > Or am I being unreasonable in this expectation ? > SELECT n1.scheme_code > FROM nav n1 > INNER JOIN nav n2 ON n1.scheme_code = n2.scheme_code > WHERE n1.sch

[SQL] Unnecessary repeat condition for a self inner join

2008-07-11 Thread Robins Tharakan
Hi, I am not sure if this is a simple (... stupid) question but I just wasted two hours optimizing a query, so I thought I should drop in to ask. The only difference between query1 and query2 (below) is that despite an explicit INNER JOIN, I have repeated the same condition for n2 (as given for n