Dear PostgreSQL developers,
I'm confused about the absence of a very simple optimization
in PostgreSQL. Suppose we have a VIEW where some columns are
expensive to be calculated:
CREATE VIEW a AS
SELECT
(... expensive calculation ...) as expensive,
count(*) as cheap
FROM
x;
where "x" is a sufficiently large table. I would expect the
following query to be very fast:
SELECT cheap FROM a;
However, it takes the same time as "SELECT * FROM a;".
In other words: The column "expensive" is calculated although
it hasn't been asked for. Of course, there are work-arounds
for that, but I wonder why PostgreSQL doesn't perform this
small optimization by itself.
I checked that behaviour with PostgreSQL 8.3.7 (Debian/Etch)
and 8.4.1 (Debian/Lenny).
Greets,
Volker
--
Volker Grabsch
---<<(())>>---
Administrator
NotJustHosting GbR