4

I am investigating high load on a PostgreSQL database on RDS. As a part of the investigation, I'm running the following query:

SELECT now()-query_start, state, query FROM pg_stat_activity ORDER BY 1 DESC;

This query returns the longest-running queries on the database. Then, I manually copy the query text to another window, and run EXPLAIN on each query to identify longer queries that need indexing.

Is there a way to automatically run EXPLAIN on each query in pg_stat_activity?

4

It's not exactly what you are looking for, but the auto_explain extension may be as close as you can get. See auto_explain

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.