Обсуждение: Row counts/data changes. Any catalog table that has this info?

Поиск
Список
Период
Сортировка

Row counts/data changes. Any catalog table that has this info?

От
"David B"
Дата:
Folks,

Is there a catalog table or location where I can go to find data counts for
tables?

It would be nice if I could do a query which returned something like:

table_name    #Rows
cust          1000
order         5000
order_detail  9500

without having to have the overhead of querying each table in turn.

If there is such a source then is it accurate as of now or last vacuum or
???

On a related note...any location where I can see the most recent date a
table was changed (insert/update/delete).


Tx in advance...
D
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.574 / Virus Database: 364 - Release Date: 1/29/2004



Re: Row counts/data changes. Any catalog table that has this info?

От
Josh Berkus
Дата:
David,

> table_name    #Rows
> cust          1000
> order         5000
> order_detail  9500

If you're willing to live with some inaccuracy, do:

SELECT relname, reltuples FROM pg_class
WHERE relkind='r';

This count gets updated when you do a VACUUM, and is seldom 100% accurate; 
however, if you VACUUM regularly it will be within 5-10%.

-- 
-Josh BerkusAglio Database SolutionsSan Francisco