Collecting regular statistics from pg_stat* views

This recipe describes how to collect the statistics needed to understand what is going on in the database system on a regular basis so that they can be used to further optimize the queries that are slow or are becoming slow as the database changes.

We have included an example of extension, called pgstatslog. It can be used to track these changes. The extension works on PostgreSQL 9.1, 9.2, 9.3 and 9.4.

Porting of this extension to PostgreSQL 9.0 is simple and can be performed as an exercise by you.

Look at the Using an installed module and Managing installed extensions recipes from Chapter 3, Configuration, for an overview of the extensions infrastructure in PostgreSQL.

Further information on extensions ...

Get PostgreSQL 9 Administration Cookbook - Second Edition 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.