Re: Improving count(*)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Improving count(*)
Дата
Msg-id 7711.1132338904@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Improving count(*)  (Richard Huxton <dev@archonet.com>)
Ответы Re: Improving count(*)  (Alvaro Herrera <alvherre@commandprompt.com>)
Список pgsql-hackers
Richard Huxton <dev@archonet.com> writes:
> Might it be possible to apply rule-style rewriting to a clause of an 
> ordinary select query? That is, is it prohibitively expensive to get PG 
> to recognise
>    SELECT count(*) FROM big_table
> and replace it with
>    SELECT sum(summary_count) FROM my_materialised_view

> This should allow you to have where-clauses and apply to a range of 
> cases. What I fear is that checking to see if the rule applies will cost 
>   too much on all those queries where it doesn't apply.

There is already code in the optimizer that does similar rewriting
for min/max queries.   However, that's a hard-wired transformation.
I don't see any very simple way to provide a user-configurable
equivalent.
        regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: MERGE vs REPLACE
Следующее
От: Grzegorz Jaskiewicz
Дата:
Сообщение: order by, for custom types