PostgreSQL includes a subsystem named the statistics collector that allows monitoring various aspects of the database internals. Each of the processes in the server sends statistics messages to the collector, which then totals the results and periodically publishes the results to where you can see them. By default (the interval is a compile-time option) statistics updates are published every half second. Each of the statistics values is available via a set of functions that return the current value, all documented at http://www.postgresql.org/docs/current/static/monitoring-stats.html.
Topics we will cover in this chapter are:
- PostgreSQL statistics views
- Table and Index statistics
- Database level statistics
- Locks
- Background writer statistics