Re: [PHP3] [OT]: SELECT COUNT(*) in Postgres - Mailing list pgsql-hackers

From Clark Evans
Subject Re: [PHP3] [OT]: SELECT COUNT(*) in Postgres
Date
Msg-id 3702BC1F.C33BB699@manhattanproject.com
Whole thread Raw
List pgsql-hackers
It seems that one topic of discussion regarding the optimizer
is that it dosen't know how many rows are in the table untill
an analyze is done.  Doing SELECT COUNT(*) seems like something
often done that also requires the number of rows in the table
to be known.  Perhaps it would be prudent to keep a running
total of the number of active rows for each table cashed?

Clark

Jordan Krushen wrote:
> I know that MySQL doesn't actually hit the tables when doing a SELECT
> COUNT(*), and it returns very quickly as a result.. On large Postgres
> tables, COUNT(*) is horrendously slow.  What I'm wondering is if anybody
> here knows a faster way to get the row count, be it an internal Postgres
> variable one can access, or if a COUNT(small_primary_key) would be faster.
> Any ideas?
>


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] libpq++
Next
From: Vince Vielhaber
Date:
Subject: Re: [HACKERS] libpq++