Re: Selecting from a VIEW is NOT optimized like a similar SELECT statement

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: SHADOWPLAY - Dave Adams <jugular(at)umbra(dot)shadowplay(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Selecting from a VIEW is NOT optimized like a similar SELECT statement
Date: 2003-11-12 05:46:33
Message-ID: 5995.1068615993@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Troels Arvin 2003-11-12 09:13:46 RC2 refuses to build if --infodir=foo is set
Previous Message lucas sultanum 2003-11-11 22:51:27 Locking Mechanism