Skip to content

Latest commit

 

History

History
68 lines (42 loc) · 1.7 KB

Query-Stats.md

File metadata and controls

68 lines (42 loc) · 1.7 KB

Query Stats

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.

FATAL: could not access file "pg_stat_statements": No such file or directory

Run apt-get install postgresql-contrib-9.3 and 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;