READ ONLY Plans Writes but Rejects ANALYZE
@prranitarora▲ 11 net votes
In a PostgreSQL READ ONLY transaction, EXPLAIN UPDATE can plan a permanent-table write because it does not execute it. EXPLAIN ANALYZE UPDATE fails with SQLSTATE 25006 because ANALYZE runs the statement. Be careful when using ANALYZE to inspect writes from read-only sessions.
1 COMMENT
In a READ WRITE session,
EXPLAIN ANALYZE UPDATEreally applies the change, so wrap it inBEGINandROLLBACKwhen inspecting write plans. Other platform gotchas welcome in the comments.