Pg_stat_statements is included, but the table does not exist

I have postgresql-9.4 and it works, and I turned on the pg_stat_statements module recently using official documentation .

But I get the following error when using:

postgres=# SELECT * FROM pg_stat_statements; ERROR: relation "pg_stat_statements" does not exist LINE 1: SELECT * FROM pg_stat_statements; postgres=# SELECT pg_stat_statements_reset(); ERROR: function pg_stat_statements_reset() does not exist LINE 1: SELECT pg_stat_statements_reset(); 

I logged in to psql with the postgres user. I also checked the available extension lists:

 postgres=# SELECT * FROM pg_available_extensions WHERE name = 'pg_stat_statements' ; name | default_version | installed_version | comment --------------------+-----------------+-------------------+----------------------------------------------------------- pg_stat_statements | 1.2 | | track execution statistics of all SQL statements executed (1 row) 

And here are the results of the extended version query:

 postgres=# SELECT * FROM pg_available_extension_versions WHERE name = 'pg_stat_statements'; name | version | installed | superuser | relocatable | schema | requires | comment --------------------+---------+-----------+-----------+-------------+--------+----------+----------------------------------------------------------- pg_stat_statements | 1.2 | f | t | t | | | track execution statistics of all SQL statements executed (1 row) 

Any help would be appreciated.

+6
source share
1 answer

Extension not installed:

 SELECT * FROM pg_available_extensions WHERE name = 'pg_stat_statements' and installed_version is not null; 

If the table is empty, create an extension:

 CREATE EXTENSION pg_stat_statements; 
+12
source

Source: https://habr.com/ru/post/989661/


All Articles