Query Stats
August 27, 2025 ยท View on GitHub
The pg_stat_statements module is used for query stats.
Installation
If you have trouble enabling query stats from the dashboard, try doing it manually.
Add the following to your postgresql.conf:
shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.track = all
pg_stat_statements.max = 10000
track_activity_query_size = 2048
Then restart PostgreSQL. As a superuser from the psql console, run:
CREATE EXTENSION pg_stat_statements;
Amazon RDS
Change shared_preload_libraries to pg_stat_statements in your Parameter Group and restart the database instance.
As a superuser from the psql console, run:
CREATE EXTENSION pg_stat_statements;
Common Issues
pg_stat_statements must be loaded via shared_preload_libraries
Follow the instructions above.
The database user does not have permission to ...
The database user is not a superuser. You can manually enable stats from the psql console with:
CREATE EXTENSION pg_stat_statements;
and reset stats with:
SELECT pg_stat_statements_reset();
Queries show up as <insufficient privilege>
For security reasons, only superusers can see queries executed by other users.
ERROR: column "total_plan_time" / "queryid" does not exist
Update the pg_stat_statements extension with:
ALTER EXTENSION pg_stat_statements UPDATE;