Re: Selecting from a VIEW is NOT optimized like a similar SELECT statement - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Selecting from a VIEW is NOT optimized like a similar SELECT statement
Date
Msg-id 5995.1068615993@sss.pgh.pa.us
Whole thread Raw
In response to Selecting from a VIEW is NOT optimized like a similar SELECT statement  (SHADOWPLAY - Dave Adams <jugular@umbra.shadowplay.net>)
List pgsql-bugs
SHADOWPLAY - Dave Adams <jugular@umbra.shadowplay.net> writes:
> When using a view on a table, a select on the view is not as optimized as
> a select directly from the table.

PG 7.3 is not very bright about pushing WHERE quals down into a
sub-select that involves DISTINCT ON.  7.4 is a tad smarter, and I think
it will handle your example nicely --- though there are certainly plenty
of similar-looking cases that are just plain not optimizable.  You might
find it interesting to compare the comments in the 7.3 and 7.4 versions
of
http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/optimizer/path/allpaths.c
in particular the 1.99-1.100 diff.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Theodore Petrosky
Date:
Subject: RC1 question of reloading data
Next
From: Tomas Szepe
Date:
Subject: Re: RC1 question of reloading data