Re: Make COUNT(*) Faster?

Поиск
Список
Период
Сортировка
От Steve Wampler
Тема Re: Make COUNT(*) Faster?
Дата
Msg-id 42CE89CA.2070607@noao.edu
обсуждение исходный текст
Ответ на Re: Make COUNT(*) Faster?  (Chris Browne <cbbrowne@acm.org>)
Ответы Re: Make COUNT(*) Faster?  (Bruno Wolff III <bruno@wolff.to>)
Re: Make COUNT(*) Faster?  (Dawid Kuroczko <qnex42@gmail.com>)
Список pgsql-sql
Chris Browne wrote:

> None of those transactions have COMMITted, so there are some 78 tuples
> "in limbo" spread across 16 transactions.
> 
> If there were some "single secret place" with a count, how would you
> suggest it address those 78 tuples and 16 transactions that aren't yet
> (and maybe never will be) part of the count?

Hmmm, I understand this and don't doubt it, but out of curiousity, how
does the current SELECT COUNT(*) handle this?  It doesn't lock the entire
table while counting (I assume) so the current implementation is really
just an approximate count in the above scenario anyway.  Or even when
not, since the true 'count' is likely to have changed by the time the
user does anything with the result of SELECT COUNT(*) on any active table
(and on an inactive table, pg_class.reltuples is nearly as good as
SELECT COUNT(*) and far faster to get to.)

I assume this has been beaten well past death, but I don't see why it
wouldn't be possible to keep pg_class.reltuples a bit more up-to-date
instead of updating it only on vacuums.

-- 
Steve Wampler -- swampler@noao.edu
The gods that smiled on your birth are now laughing out loud.


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

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: two sums in one query
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: Make COUNT(*) Faster?