SHADOWPLAY - Dave Adams <jugular(at)umbra(dot)shadowplay(dot)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