# Stop rewriting data that hasn't changed

Prompt · Writes and ingestion · PG06

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

## Prompt

```text
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.

**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.

**Changes:** Changes nothing

**Sessions:** Look first, then fix in a new session

## Related

- [Work repeated for nothing](https://atlasscope.dev/prompts/work-repeated-for-nothing): Finds work redone on every request or screen redraw when nothing it depends on changed.
- [Parallel work with no limit](https://atlasscope.dev/prompts/parallel-work-with-no-limit): Finds work run in parallel with no limit, which can swamp the database connections or an outside service.
- [Map every place that writes to the database](https://atlasscope.dev/prompts/map-every-place-that-writes-to-the-database): Several jobs, functions, APIs or agents change the same data, or nobody is sure who owns it.
- [Is our ingestion process more complicated than necessary?](https://atlasscope.dev/prompts/is-our-ingestion-process-more-complicated-than-necessary): The import pipeline is long, slow to correct, or does the same work at several stages.
- [Find the true sources of database waste](https://atlasscope.dev/prompts/find-the-true-sources-of-database-waste): The bill is high, CPU or disk usage is high, storage keeps growing, or you suspect bloat.

Source: https://atlasscope.dev/prompts/stop-rewriting-data-that-hasnt-changed
