Re: Another optimizer question - Mailing list pgsql-general

From Tom Lane
Subject Re: Another optimizer question
Date
Msg-id 5258.979853409@sss.pgh.pa.us
Whole thread Raw
In response to Another optimizer question  ("Gordan Bobic" <gordan@freeuk.com>)
List pgsql-general
"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

pgsql-general by date:

Previous
From: "Oliver Elphick"
Date:
Subject: Re: Troubles with performances
Next
From: "Adam Lang"
Date:
Subject: Re: Re: MS Access data to PostgrSQL data