Check out our new Resources section: Read through our eBooks and learn how customers are using pganalyze. See all resources

Step 2: Enable pg_stat_statements

Install official PostgreSQL contrib package

On your database server, make sure that the extensions package is installed:

sudo yum install postgresql-contrib

Enable pg_stat_statements

Run the following SQL statement as a superuser, to enable the pg_stat_statements extension:

ALTER SYSTEM SET shared_preload_libraries = 'pg_stat_statements';

Restart the PostgreSQL daemon

If you have not used pg_stat_statements before, you will need a full Postgres restart to enable it for the first time:

sudo systemctl restart postgresql

Verify that pg_stat_statements returns data

As a superuser, run the following statements:

SELECT calls, query FROM pg_stat_statements LIMIT 1;

If you have configured your database correctly, this will return a result like this:

 calls | query
     8 | SELECT * FROM t WHERE field = ?
(1 row)

If you get an error you might not have restarted the server. If you get stuck feel free to reach out to us, we're happy to help.

Next we continue by installing the pganalyze collector:

Proceed to Step 3: Install the collector

Couldn't find what you were looking for or want to talk about something specific?
Start a conversation with us →