pghero: Query stats must be enabled for slow queries

After installation Mastodon under the official guide, I notice that PgHero keep showing this error. Here is the way to solve it.

1. Edit postgresql.conf

sudo vim /etc/postgresql/9.5/main/postgresql.conf

Add the following to your postgresql.conf:

sharedpreloadlibraries = 'pgstatstatements' pgstatstatements.track = all pgstatstatements.max = 10000 trackactivityquery_size = 2048

Then restart the PostgreSQL server: sudo systemctl restart postgresql

2. Create extension

sudo -u postgres psql

postgres=# \c mastodon_production

mastodon_production=# CREATE extension pg_stat_statements;

3. Refresh your PgHero Page

All items are green!