Table statistics

Basic statistics about each table in your database are available in the view pg_stat_all_tables. Since you probably don't want that cluttered by the many system catalog tables, the data in there is split into two additional views: pg_stat_sys_tables, which only shows the system tables and pg_stat_user_tables, which as you might expect only shows your tables. In most cases pg_stat_user_tables is the one you'll want to look at.

The first useful thing you can use this data for is monitoring how well vacuum is working on your database. You get estimated live and dead tuple counts and timestamps for when vacuum and autovacuum last processed the table (these are not all available before version 8.3). Information about how to monitor ...

Get PostgreSQL 9.0 High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.