How to I reset the statistics for a Heroku Postgres database?

Issue

I'd like to reset the pg_stats table to measure the performance of database changes.

Resolution

The pg_stat_statements are where Postgres records all kinds of performance information. This gets used in several Heroku commands including pg:diagnose, pg:outliers and pg:long-running-queries.

You can reset the pg_stat_statements directly in a psql console like so: heroku pg:psql <database> -a <app name> -c "SELECT pg_stat_statements_reset();".

Alternatively you can do this in two ways via the CLI:

  1. with the pg:outliers command:
heroku pg:outliers --reset
  1. with Heroku PG extras plugin also:
heroku plugins:install heroku-pg-extras
heroku pg:stats-reset -a APP_NAME

Ask on Stack Overflow

Engage with a community of passionate experts to get the answers you need

Ask on Stack Overflow

Heroku Support

Create a support ticket and our support experts will get back to you

Contact Heroku Support