Book Image

PostgreSQL 9 Administration Cookbook - Second Edition

Book Image

PostgreSQL 9 Administration Cookbook - Second Edition

Overview of this book

Table of Contents (19 chapters)
PostgreSQL 9 Administration Cookbook Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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 can be found in the PostgreSQL documentation at http://www.postgresql.org/docs/current/static/sql-createextension.html.

Note

Chapter 10, Publishing Your Code as PostgreSQL Extensions, of PostgreSQL Server Programming, Hannu Krosing, Jim Mlodgenski...