pghero on PostgresApp pg_stat_statements must be loaded via shared_preload_libraries

Nick Ginanto picture Nick Ginanto · Jan 26, 2015 · Viewed 13.6k times · Source

I have this error

  PG::ObjectNotInPrerequisiteState: ERROR:  pg_stat_statements must be loaded via shared_preload_libraries

on localhost. Using osx (10.9.5), PostgresApp 9.3.1.0 and pghero gem

Going to postgresql.conf located in ~/Library/Application Support/Postgres93/var I have this in the top of the file

shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.track = all

So, either this is the correct postgresql.conf, or something in my setup is broken..

Any ideas?

Answer

Martin Seener picture Martin Seener · Jun 9, 2016

You have to restart the Postgresql Server in order to load the shared library and afterwards execute

CREATE EXTENSION pg_stat_statements;

in the database you want to monitor.

Additionally you will have to edit the following line in postgresql.conf

shared_preload_libraries = ''

To

shared_preload_libraries = 'pg_stat_statements'

A restart of the PSQL service is required.