Join more than 25k Postgres enthusiasts and sign up for our newsletter!

Step 4: Test and Verify

At this point, your pganalyze setup should be ready to collect EXPLAIN plans. Since you may not have any slow queries in your system right now, we can generate a synthetic slow query that we can use to confirm everything is working.

The collector includes a flag to do this for you automatically, based on your auto_explain.log_min_duration:

heroku run -a [your-collector-app-name] -- collector --test-explain

This will run an artificially slow query using the Postgres pg_sleep function. It will produce output similar to the following:

Running collector --test-explain on ⬢ [your-collector-app-name]... up, run.3163
2024/09/23 09:30:19 I Running collector test with pganalyze-collector 0.58.0
2024/09/23 09:30:19 I [DATABASE_URL] Emitted test explain; check pganalyze EXPLAIN Plans page for result

Assuming the collector is running in the background, after a few minutes you should then see EXPLAIN plans show up in the pganalyze EXPLAIN plan list:

Screenshot of EXPLAIN list in pganalyze

When you select one of the query executions in this list, you will see details of the corresponding plan:

Screenshot of EXPLAIN plan in pganalyze

From now on, you will now get EXPLAIN plans automatically in the pganalyze UI, for all your slow queries.

Learn more about how pganalyze works with EXPLAIN data.


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