Making SELECT COUNT(seed) FROM fast

Поиск
Список
Период
Сортировка
От Gerald Gutierrez
Тема Making SELECT COUNT(seed) FROM fast
Дата
Msg-id IIEOKIIOJMELMIFMMEBFCEDMCBAA.gutz@kalador.com
обсуждение исходный текст
Ответы Re: Making SELECT COUNT(seed) FROM fast  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-sql
Hi all.

I have a table with about 5 million rows in it. I need to be able to get the
exact number of rows in the table at runtime. So I tried the following:

xxx=> explain select count(seed) from mytable;
NOTICE:  QUERY PLAN:

Aggregate  (cost=103152.27..103152.27 rows=1 width=4) ->  Seq Scan on mytable(cost=0.00..89756.42 rows=5358342
width=4)

EXPLAIN
xxx=>

Actually executing this query takes about 2 minutes on a P3-800MHz machine
with 512MB of RAM.

I have an index on the seed table, and I have done VACUUM ANALYZE on the
table after inserting the rows. Is there any way I can get this to be fast?

Thanks.


Gerald.



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

Предыдущее
От: Kovacs Zoltan
Дата:
Сообщение: Re: enumerating rows
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: Making SELECT COUNT(seed) FROM fast