Catching more queries

By default, the pg_stat_statements module only tracks the first 1,000 queries it encounters during database operation. Normally, this is enough, especially in versions of PostgreSQL above 9.1. Newer versions provide better aggregation, because they remove SQL variables and constants from the query before including them in the view. However, older versions or databases that experience a high variance in query construction may want to increase this number. To do that, add this line to the postgresql.conf file:

pg_stat_statements.max = 10000 

Then, we have to restart PostgreSQL again. Once this is finished, the pg_stat_statements module will track 10,000 queries instead of 1,000. Feel free to experiment with other values. ...

Get PostgreSQL High Availability 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.