Prompt·Writes and ingestion·PG06

Stop rewriting data that hasn't changed

Upserts and updates run at high volume, imports are costly, or vacuum and write-ahead log churn look high.

Markdown
Prompt
Investigate how much database write activity actually changes meaningful information. Find repeated upserts, unchanged updates, unnecessary delete-and-reinsert operations, repeated index maintenance and cascading refreshes. Measure their cost where practical and determine which writes can be eliminated without changing correctness, history or recovery behavior.
What it returns
Statement counts, the share of writes that really change a row, dead-row and churn figures, index and WAL effects where measurable, and before-and-after tests on a copy.
Skip it when
Write volume is small, or every write is a change that has to happen.
Avoid
Suppressing deliberate last-seen timestamps, trigger side effects, version counters or refreshes that are meant to happen.
Changes
Changes nothing
Sessions
Look first, then fix in a new session
Tools
Needs: the repository and read-only database access. Helps: query statistics (pg_stat_statements).
Works on
Any PostgreSQL host: Supabase, Neon, RDS, Cloud SQL or self-hosted.

Related prompts

More in Writes and ingestion.