PostgreSQL EXPLAIN ANALYZE Analyzer
Paste the output of EXPLAIN ANALYZE. dbCove AI finds the node that costs the time, says why and gives the fix as runnable SQL.
How to get the plan in PostgreSQL
EXPLAIN ANALYZE runs the statement and measures every node:
EXPLAIN (ANALYZE, BUFFERS, VERBOSE) SELECT ...;Measure an UPDATE or DELETE without keeping its changes:
BEGIN; EXPLAIN (ANALYZE, BUFFERS) UPDATE ...; ROLLBACK;The JSON format works too:
EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) SELECT ...;auto_explain writes the plan of every statement slower than a threshold to the log:
LOAD 'auto_explain'; SET auto_explain.log_min_duration = '1s'; SET auto_explain.log_analyze = on;What it looks for in a PostgreSQL plan
Actual time and rows are per loop. A node that runs 482,113 times at 0.07 ms costs half a minute.
rows=1 planned against hundreds of thousands returned: where the planner picked a nested loop it should not have.
Rows read and thrown away: the missing or unusable index.
Sort Method external merge and Hash Batches above 1, when work_mem is too small for this query.
shared read against shared hit: what came from disk rather than from cache.
This was one statement. dbCove watches all of them.
On your own databases dbCove AI has the history of every plan, every wait and every change, so it can tell you why a plan flipped, not only that it is slow. Free for 2 databases of each engine.
Questions
Is what I paste kept?
It is sent to our AI provider to be explained and kept by us for up to 12 months to improve the tools; the AI provider does not keep it or train on it. Remove passwords and personal data before you paste.
Does EXPLAIN ANALYZE run the query?
Yes, it runs the statement to measure it. For INSERT, UPDATE or DELETE, run it between BEGIN and ROLLBACK.
Text or JSON?
Both work. Text is shorter, so more of a large plan fits in the limit of about 180,000 characters.
Which versions does it read?
PostgreSQL 10 and later, including Amazon RDS, Aurora PostgreSQL, Azure Database for PostgreSQL and Cloud SQL.