patternsqlMinor
pg_stat_statements not found even with "shared_preload_libraries = 'pg_stat_statements'
Viewed 0 times
pg_stat_statementswithshared_preload_librariesfoundevennot
Problem
I have followed the instructions given below:
http://www.postgresql.org/docs/9.3/static/pgstatstatements.html
... to the effect of adding the following lines:
In file
update
After executing:
And then doing:
... I now get:
system details
I am running on `Ubuntu 14.
http://www.postgresql.org/docs/9.3/static/pgstatstatements.html
... to the effect of adding the following lines:
# postgresql.conf
shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.max = 10000
pg_stat_statements.track = allIn file
postgresql.conf and then restarting the server but the table pg_stat_statements is still not visible:$ cat /usr/share/postgresql/9.3/postgresql.conf | grep -A3 ^shared_preload_libraries
shared_preload_libraries = 'pg_stat_statements' # (change requires restart)
pg_stat_statements.max = 10000
pg_stat_statements.track = all
$ sudo /etc/init.d/postgresql restart
* Restarting PostgreSQL 9.3 database server [ OK ]
$ psql -U postgres
psql (9.3.10)
Type "help" for help.
postgres=# select count(*) from pg_stat_activity;
count
-------
1
(1 row)
postgres=# select count(*) from pg_stat_statements;
ERROR: relation "pg_stat_statements" does not existupdate
After executing:
sudo apt-get install postgresql-contrib-9.3And then doing:
$ psql -U postgres
psql (9.4.5, server 9.3.10)
Type "help" for help.
postgres=# create extension pg_stat_statements;
CREATE EXTENSION
postgres=# \dx
List of installed extensions
Name | Version | Schema | Description
--------------------+---------+------------+-----------------------------------------------------------
pg_stat_statements | 1.1 | public | track execution statistics of all SQL statements executed
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
(2 rows)
postgres=# \quit
$ sudo /etc/init.d/postgresql restart
* Restarting PostgreSQL 9.3 database server [OK]... I now get:
postgres=# select * from pg_stat_statements ;
ERROR: pg_stat_statements must be loaded via shared_preload_librariessystem details
I am running on `Ubuntu 14.
Solution
Recent versions of Postgres install conf files in different locations than they used to be in. There is sometimes a template .conf file that exists (but is not actually used), and then also an active .conf file (in a completely different location). I discovered this by scouring through the /etc/init.d files. It's possible that the .conf file you edited is not actually the one that is being used by the database.
You can find the location of the conf file used by your database by connecting to the database and querying
Here is a link to your follow up question (in case anyone in the future finds it useful)
You can find the location of the conf file used by your database by connecting to the database and querying
SHOW config_fileHere is a link to your follow up question (in case anyone in the future finds it useful)
Context
StackExchange Database Administrators Q#124054, answer score: 6
Revisions (0)
No revisions yet.