Hands-on Lab·PostgreSQL
PostgreSQL Statistics Views
Cache hit ratio, sequential scans, dead tuples and unused indexes - and a reset that left the table reporting zero rows while holding four hundred thousand.
Monitoring and Operations Guide 41 of 47 Intermediate
- OSUbuntu 26.04 LTS (resolute)
- PostgreSQL18.6-0ubuntu0.26.04.1
- Host2 core / 4 GB, 400,000-row test table
- TimeAbout 17 min
- Reviewed27 August 2026
Written against the versions above. Since PostgreSQL 15 these counters live in shared memory rather than in a separate collector process, and survive a clean shutdown. `stats_fetch_consistency` controls how they behave inside a transaction.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| db-a01 | 192.168.0.81 | Ubuntu 26.04 LTS | Primary / Source / Replica Set Member 1 | 2 Core | 4 GB | 50 GB |
Before you start
- The
appdbdatabase with theeventstable and its indexes.
-
The whole-database counters
-
How each table is being read
-
Find the indexes earning nothing
-
Block-level I/O per table
-
Watch a counter move
-
Reset the counters, and find out what a reset does not touch