Counting all rows

From: "Stefan Arentz" <stefan(dot)arentz(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Counting all rows
Date: 2007-06-23 10:15:11
Message-ID: adf34c300706230315y43ba92daqf0804b7c377ffd29@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I need to get statistics from a bunch of tables. Simply the number of
records in them.

The query plan looks like this:

=> explain select count(id) from stuff;
QUERY PLAN
-------------------------------------------------------------------
Aggregate (cost=1629.69..1629.70 rows=1 width=8)
-> Seq Scan on stuff (cost=0.00..1517.75 rows=44775 width=8)

The sequential scan kind of worries me. Is there a better/faster way to do this?

S.
S.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andreas Kretschmer 2007-06-23 10:38:56 Re: Counting all rows
Previous Message A. R. Van Hook 2007-06-23 09:15:05 Re: join problem