Re: select count(*) performance

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: select count(*) performance
Дата
Msg-id b42b73150708100444x76d8881fkca87772272859d8a@mail.gmail.com
обсуждение исходный текст
Ответ на select count(*) performance  (runic <runic@gmx.de>)
Список pgsql-performance
On 8/8/07, runic <runic@gmx.de> wrote:
> Hello Group,
>
> I'm new in PostgreSQL Business, therefore please forgive me a "newbie"
> Question. I have a table with ca. 1.250.000 Records. When I execute
> a "select count (*) from table" (with pgAdmin III)  it takes about 40
> secs.
> I think that takes much to long. Can you please give me hints, where
> I can search for Improvements?

This is a FAQ.  This operation is optimized in some other database
engines but not in PostgreSQL due to way the locking engine works.
There are many workarounds, maybe the easiest is to get an approximate
count using
select reltuples from pg_class where relname = 'your_table' and relkind = 'r';

merlin

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

Предыдущее
От: "Merlin Moncure"
Дата:
Сообщение: Re: Dell Hardware Recommendations
Следующее
От: Brian Hurt
Дата:
Сообщение: Re: select count(*) performance