Calculation of unused columns

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux