Make COUNT(*) Faster?

Поиск
Список
Период
Сортировка
От Varun Mehta
Тема Make COUNT(*) Faster?
Дата
Msg-id 9EF2931D-1097-470D-8ECB-59D00166C96F@apple.com
обсуждение исходный текст
Ответы Re: Make COUNT(*) Faster?
Список pgsql-sql
Hello all you PostgreSQL/SQL gurus!

I've started using PostgreSQL pretty recently, and I am quite  
disturbed about the performance of a simple SELECT COUNT(*) FROM  
table.  What should (in my mind) be a nearly instantaneous operation  
instead takes nearly 700ms in a table with only 87k rows of data!

If I run an EXPLAIN on this query I can see that it is doing a  
sequential scan, which seems quite needless, as surely this  
information is cached in some secret location.

It is very possible that I am missing something, so I ask you: is  
there a faster way to find out how many rows are in a table?  I've  
tried doing a COUNT(column) where I have an index on column, but it  
still does a sequential scan and it is still very very slow.  What  
are my options?

I offer you many thanks in advance,
Varun Mehta


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

Предыдущее
От: Michael Fuhr
Дата:
Сообщение: Re: getting back autonumber just inserted
Следующее
От: PFC
Дата:
Сообщение: Re: getting back autonumber just inserted