Re: Number of rows in a table

From: Christopher Browne <cbbrowne(at)libertyrms(dot)info>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Number of rows in a table
Date: 2003-09-03 03:15:11
Message-ID: 60isoa4l6o.fsf@dev6.int.libertyrms.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

ron(dot)l(dot)johnson(at)cox(dot)net (Ron Johnson) writes:
> Well yes, but in most other databases, there is a system table that
> stores the approximate number of records in each table, and querying
> that system table is a *lot* faster than sequentially reading a 100M
> row table.

That relation would be pg_class, the domain is called "reltuples."

It is only about as accurate as the last vacuum and/or analyze has
made it, so if you don't fairly regularly vacuum tables, the
approximation may not be very good. (Which is an argument in favor of
vacuuming fairly often...)
--
select 'cbbrowne' || '@' || 'libertyrms.info';
<http://dev6.int.libertyrms.com/>
Christopher Browne
(416) 646 3304 x124 (land)

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message glenn 2003-09-03 05:07:35 setting next value of an established sequence
Previous Message Tyler Colbert 2003-09-03 01:44:51 Re: using dates in pgsql