Re: Number of rows in a table - Mailing list pgsql-novice

From Christopher Browne
Subject Re: Number of rows in a table
Date
Msg-id 60isoa4l6o.fsf@dev6.int.libertyrms.info
Whole thread Raw
In response to Re: Number of rows in a table  ("paul butler" <paul@entropia.co.uk>)
List pgsql-novice
ron.l.johnson@cox.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)

pgsql-novice by date:

Previous
From: Luis Hernán Otegui
Date:
Subject: unsubscribe
Next
From: "Tyler Colbert"
Date:
Subject: Re: using dates in pgsql