Re: Long count(*) time

Поиск
Список
Период
Сортировка
От Richard Broersma Jr
Тема Re: Long count(*) time
Дата
Msg-id 721682.74917.qm@web31809.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на Long count(*) time  ("David Monarchi" <david.e.monarchi@gmail.com>)
Список pgsql-novice
--- David Monarchi <david.e.monarchi@gmail.com> wrote:

> 70 seconds seems to be a long time for this kind of query.  Is this normal?

Do to the nature of PostgreSQL's MVCC system, all Count(*) operations with no where clauses will
trigger a full table scan.  You could possible shave off a some time if you perform a VACUUM FULL
on this table.  Vacuum full will recover all the space from dead tuples.  The end result is that
fewer pages left will require less time to scan.

However, if you have a good auto-vacuum policy implemented you can get a very close estimate of
the number of records in you table in much less time.  This link has a good example of how this is
done:
http://www.commandprompt.com/blogs/joshua_drake/2007/08/how_many_rows_do_i_have_anyway/

Regards,
Richard Broersma Jr.

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

Предыдущее
От: Jon Sime
Дата:
Сообщение: Re: Long count(*) time
Следующее
От: Phillip Smith
Дата:
Сообщение: Re: pg_hba.conf not right