Re: Why Select Count(*) from table - took over 20 minutes?

Поиск
Список
Период
Сортировка
От Jasen Betts
Тема Re: Why Select Count(*) from table - took over 20 minutes?
Дата
Msg-id iarcnr$sp4$1@reversiblemaps.ath.cx
обсуждение исходный текст
Ответ на what can depend on index  (Szymon Guz <mabewlun@gmail.com>)
Список pgsql-general
On 2010-10-26, John R Pierce <pierce@hogranch.com> wrote:
>
> count(*) has to read the whole table to get the accurate count.   The
> reason for this is that different clients can see different versions of
> that table, for instance, if client A is already in a transaction, and
> client B then does an INSERT, the two clients will see different values
> for the count.

They may or may not. the default transaction isolation level "read commited"
allows a session to see most changes that were committed externally after the
start of the transaction.

Tlso the index may include deleted rows.
which is another reason count(*) does a table scan.

--
ɹǝpun uʍop ɯoɹɟ sƃuıʇǝǝɹ⅁


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

Предыдущее
От: Dimitri Fontaine
Дата:
Сообщение: Re: Group by and limit
Следующее
От: Gerrit Seré
Дата:
Сообщение: Compiling PostgreSql 9.0 on Sparc Solaris (64 bit)