Re: [HACKERS] Much Ado About COUNT(*)

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: [HACKERS] Much Ado About COUNT(*)
Дата
Msg-id 87y8evtl2q.fsf@stark.xeocode.com
обсуждение исходный текст
Ответ на Re: [HACKERS] Much Ado About COUNT(*)  ("Frank D. Engel, Jr." <fde101@fjrhome.net>)
Список pgsql-general
"Frank D. Engel, Jr." <fde101@fjrhome.net> writes:

> Yep, that could cause problems.  Okay, now I'm joining the program.
>
> The only thing I can see that would fix this
> ...

There are well understood mechanisms to fix this. It's a "SMOP" or "simple
matter of programming". What you would do is insert into a summary table a
record that indicates how many records you've inserted into the master table.
Periodically you have some daemon collect up those records and replace them
with a single record.

But this can be done already by hand and it's not clear having the database do
it automatically is necessarily a good idea. It would impose a cost on every
insert when most of the time it wouldn't be useful.

Moreover this is just a special case of a general problem called "materialized
views". If it were added to the database it would probably be more worthwhile
implementing a more general feature that could handle other aggregate
functions besides count(*) as well as other types of queries besides simple
unqualified aggregates.

--
greg

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

Предыдущее
От: Jeff Davis
Дата:
Сообщение: Re: Problems with a trigger
Следующее
От: John DeSoi
Дата:
Сообщение: Re: speaks psql unicode?