pg_stat_statements enabled, but the table does not exist

Extension isn't installed:

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

If the table is empty, create the extension:

CREATE EXTENSION pg_stat_statements;

I've faced with this issue at configuring Percona Monitoring and Management (PMM) because by some strange reason PMM connecting to database with name postgres, so pg_stat_statements extension have to be created in this database:

yourdb# \c postgres
postgres# CREATE EXTENSION pg_stat_statements SCHEMA public;

Follow below steps:

  • Create the extension

    CREATE EXTENSION pg_stat_statements;
    
  • Change in config

    alter system set shared_preload_libraries='pg_stat_statements';
    
  • Restart

    $ systemctl restart postgresql
    
  • Verify changes applied or not.

    select * from pg_file_Settings where name='shared_preload_libraries';
    

    The applied attribute must be 'true'.