Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pghero on PostgresApp pg_stat_statements must be loaded via shared_preload_libraries

Tags:

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?

like image 819
Nick Ginanto Avatar asked Jan 26 '15 08:01

Nick Ginanto


People also ask

What is Shared_preload_libraries?

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 ).

What is Pg_stat_statements?

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.

Where is Pg_stat_statements?

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.


2 Answers

Create extension by executing following query

CREATE EXTENSION pg_stat_statements 
like image 39
compyutech Avatar answered Oct 01 '22 04:10

compyutech


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.

like image 82
Martin Seener Avatar answered Oct 01 '22 02:10

Martin Seener