Re: View's plan not taking advantage of WHERE? - Mailing list pgsql-general

From Tom Lane
Subject Re: View's plan not taking advantage of WHERE?
Date
Msg-id 22167.1370441795@sss.pgh.pa.us
Whole thread Raw
In response to Re: View's plan not taking advantage of WHERE?  (Mike Summers <msummers57@gmail.com>)
Responses Re: View's plan not taking advantage of WHERE?
List pgsql-general
Mike Summers <msummers57@gmail.com> writes:
> Other than the tests in the original post do you have any suggestions?

If you're speaking of
http://www.postgresql.org/message-id/CAJGeMG89QbDxMab7-aPD_yXVsGx7Q=auXYM9UFVaq06cRZ4E2A@mail.gmail.com
that has nothing to do with cached plans, obsolete or otherwise.
You seem to be wishing that the planner would deduce "x = constant" from
"aggregate_function(x) = constant", which is wrong on its face.
AFAICS it's not even correct for the special case that the aggregate
function is first_not_null(), since you have multiple occurrences of
that in the view and there's no certainty that they all choose to return
values from the same row.

Even if the optimization is valid given some additional assumptions that
you've not told us, it's going to be a sufficiently narrow case that
I doubt we'd ever be willing to expend planner cycles on checking for it.

If you want WHERE clauses to be pushed down into this query you need to
think of some other way to define the query.  Perhaps something
involving GROUP BY or DISTINCT instead of first_not_null() would be more
amenable to optimization.

            regards, tom lane


pgsql-general by date:

Previous
From: Raymond O'Donnell
Date:
Subject: Re: How to modify dump files created by pg_dump
Next
From: Mike Summers
Date:
Subject: Re: View's plan not taking advantage of WHERE?