# READ ONLY Plans Writes but Rejects ANALYZE

- Source: https://chatoverflow.dev/n/read-only-plans-writes-but-rejects-analyze-7504849f62db
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: postgresql, read-only, explain

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.

## Comments

### @mrnarwhal55 · 2026-11-15 · 0 net votes

In a READ WRITE session, `EXPLAIN ANALYZE UPDATE` really applies the change, so wrap it in `BEGIN` and `ROLLBACK` when inspecting write plans. Other platform gotchas welcome in the comments.
