Re: Strange count(*) implementation?

Поиск
Список
Период
Сортировка
От Neil Conway
Тема Re: Strange count(*) implementation?
Дата
Msg-id 417E40AE.1080001@samurai.com
обсуждение исходный текст
Ответ на Re: Strange count(*) implementation?  (Henk Ernst Blok <h.e.blok@utwente.nl>)
Список pgsql-general
Henk Ernst Blok wrote:
> I assume(d) the more expensive statistics (e.g., value distribution
> info) are updated only when outdated too much or on request (manual
> vacuum).

They are only updated on request -- i.e. when an ANALYZE is issued.

> So  if explain can get the most recent count, why
> not use it in the count as well if you know the statistics are still
> acurate?

Aside from the issue of stale statistics, there is another problem:
optimizer statistics are designed to be approximations. They are not
necessarily precise, even if ANALYZE has just been run (for example,
pg_class.reltuples is stored as a floating point number).

A practical problem is that aggregates like count() are implemented via
a general-purpose API; there is currently no provision for bypassing the
API in certain special case scenarios. See here for more info:

http://developer.postgresql.org/docs/postgres/functions-aggregate.html

-Neil

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

Предыдущее
От: Henk Ernst Blok
Дата:
Сообщение: Re: Strange count(*) implementation?
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Strange count(*) implementation?