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