Re: Performance of count(*)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/22/07, Andreas Tille <tillea@xxxxxx> wrote:
I just try to find out why a simple count(*) might last that long.
At first I tried explain, which rather quickly knows how many rows
to check, but the final count is two orders of magnitude slower.

You can get the approximate count by selecting reltuples from
pg_class.  It is valid as of last analyze.

As others suggest select count(*) from table is very special case
which non-mvcc databases can optimize for.  There are many reasons why
this is the case and why it explains nothing about the relative
performance of the two databases.   This is probably #1 most
frequenctly asked question to -performance...there is a wealth of
information in the archives.

merlin


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux