neon-postgres-egress-optimizer
Postgres Egress Optimizer
When to Use
Use when diagnosing Postgres network transfer costs, unbounded or wide SELECTs, frequent repeated reads, or unexpected Neon egress bills.
Guide the user through diagnosing and fixing application-side query patterns that cause excessive data transfer (egress) from their Postgres database. Most high egress bills come from the application fetching more data than it uses.
Measurement and database boundaries
pg_stat_statements.rows counts rows retrieved or affected, not network bytes or SELECT-only egress. Treat these rankings as hypotheses and corroborate with representative result widths and provider billing/transfer metrics. Preserve existing production statistics; do not reset shared counters merely to investigate a bill. Compare time-window deltas or use an explicitly approved isolated measurement window. Extension creation, statistic resets and neon config apply are mutations requiring the matching scope; configured TTL can delete branches, so verify the exact branch and backup/recovery policy first.
Step 1: Diagnose
Identify which queries transfer the most data. The primary tool is the pg_stat_statements extension.