"Gordan Bobic" <gordan@freeuk.com> writes:
> SELECT * FROM Table1 INNER JOIN Table2 ON (Table1.Field1 = Table2.Field1)
> WHERE Table1.Field1 = 'SomeValue';
> [ is slow, but this is fast: ]
> SELECT * FROM Table1 INNER JOIN Table2 ON (Table1.Field1 = Table2.Field1)
> WHERE Table1.Field1 = 'SomeValue' AND Table2.Field1 = 'SomeValue';
You're correct, we do not deduce the latter from the former, and so the
first example does not realize that it could use a constrained indexscan
over Table2.
Maybe we should try to do this, but I suspect we'd waste more cycles
trying than we'd make back on the queries where it helps.
regards, tom lane