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.
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
- Work repeated for nothingPromptFinds work redone on every request or screen redraw when nothing it depends on changed.
- Parallel work with no limitPromptFinds work run in parallel with no limit, which can swamp the database connections or an outside service.
- Map every place that writes to the databasePromptSeveral jobs, functions, APIs or agents change the same data, or nobody is sure who owns it.
- Is our ingestion process more complicated than necessary?PromptThe import pipeline is long, slow to correct, or does the same work at several stages.
- Find the true sources of database wastePromptThe bill is high, CPU or disk usage is high, storage keeps growing, or you suspect bloat.
More in Writes and ingestion.