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?
shared_preload_libraries is a server configuration parameter determining which libraries are to be loaded when PostgreSQL starts. Any libraries which use shared memory must be loaded via this parameter. shared_preload_libraries was added in PostgreSQL 7.4 (as preload_libraries ).
The pg_stat_statements module provides a means for tracking planning and execution statistics of all SQL statements executed by a server. The module must be loaded by adding pg_stat_statements to shared_preload_libraries in postgresql. conf , because it requires additional shared memory.
Pg_stat_statements is what is known as a contrib extension, found in the contrib directory of a PostgreSQL distribution. This means it already ships with Postgres and you don't have to go and build it from source or install packages. You may have to enable it for your database if it is not already enabled.
Create extension by executing following query
CREATE EXTENSION pg_stat_statements
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With