# Make ingestion simpler and cheaper

Recipe · Bugs, speed and data · RDBR02

Maps everything writing to your Postgres tables, traces one full import end to end, trims redundant steps and no-op writes, and keeps retries safe.

**Use it when:** Postgres imports are slow, expensive, fragile on retry, or unnecessarily multi-staged.

## Steps

1. Map writers & trace one full import: see every writer and cut redundant stages (read-only)
2. Check no-op writes, safe reruns & rule ownership: measure unchanged rewrites, test retries, and untangle split validation (read-only / separate copy)
3. Apply one simplification at a time: keep provenance and correction support intact
4. Verify on reference inputs: prove identical output, less write work, and safe retries on a separate test database

## As one prompt

```text
Make ingestion simpler and cheaper. Cut wasted Postgres import work without losing source traceability or safe retries.

Run these steps one at a time. Wait for my yes after each step. Stay read-only during Steps 1 and 2. Anything that changes state (replays or rebuild tests) runs only on a separate database with safe test data, never on production.

Step 1 (map writers & trace one import — read-only): Map every script, job, API, trigger, and function that writes to the target tables, flagging conflicting writers. Then trace one complete import from raw source to final rows to spot redundant parsing, staging tables, duplicate validation, and extra writes. Bring back: a writer map (file:line), one full import trace, and the simplest path that keeps provenance and recovery checkpoints.

Step 2 (churn, retries & split rules — read-only / test copy, run only what applies): Check what share of writes rewrite unchanged rows, whether retries or out-of-order files duplicate/corrupt data (never trusting ON CONFLICT alone), and whether validation rules are duplicated across app code and SQL triggers. Bring back: unchanged-write share, unsafe retry cases (file:line), and clearest rule ownership.

Step 3 (incremental fix): After I approve, simplify one confirmed bottleneck at a time while preserving provenance, intentional timestamps, and correction handling.

Step 4 (verify on a test copy): Prove on a separate database that reference inputs produce identical records with measurably fewer writes and safe reruns.

Start your report in plain English: what you found, what it means, and whether I need to do anything. Put files, lines and commands underneath.
```

Source: https://www.atlasscope.dev/prompts/make-ingestion-simpler-and-cheaper-rdbr02
