Re: [PHP3] [OT]: SELECT COUNT(*) in Postgres

From: Clark Evans <clark(dot)evans(at)manhattanproject(dot)com>
To: hackers(at)postgreSQL(dot)org
Cc: Jordan Krushen <jordan(at)elecomm(dot)net>
Subject: Re: [PHP3] [OT]: SELECT COUNT(*) in Postgres
Date: 1999-04-01 00:21:51
Message-ID: 3702BC1F.C33BB699@manhattanproject.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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?
>

Browse pgsql-hackers by date

  From Date Subject
Next Message Vince Vielhaber 1999-04-01 00:30:20 Re: [HACKERS] libpq++
Previous Message Tom Lane 1999-04-01 00:07:08 Re: [HACKERS] libpq++