Calculation of unused columns

Поиск
Список
Период
Сортировка
От Volker Grabsch
Тема Calculation of unused columns
Дата
Msg-id 20091017225816.GA21163@flap
обсуждение исходный текст
Ответы Re: Calculation of unused columns  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-performance
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

В списке pgsql-performance по дате отправления:

Предыдущее
От: Jeff Janes
Дата:
Сообщение: Re: Indexes on low cardinality columns
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Calculation of unused columns