Prompt·Performance and maintenance·PG13
Find the true sources of database waste
The bill is high, CPU or disk usage is high, storage keeps growing, or you suspect bloat.
Prompt
Measure which tables, indexes, queries and maintenance activities consume the most storage, execution time and write resources. Distinguish useful capacity from avoidable waste, including unused indexes, row churn, bloat, poor plans and excessive scans. Recommend changes based on observed workload and realistic savings, not generic optimization rules.
- What it returns
- Table and index sizes, the top statements, usage counts, dead-row and maintenance figures, EXPLAIN output and the savings you expect.
- Skip it when
- Usage and cost are small and steady.
- Avoid
- Judging an index from a code search alone, or looking only at query time and ignoring write cost.
- Changes
- Changes nothing
- Sessions
- Look first, then fix in a new session
- Tools
- Needs: read-only database access and query statistics (pg_stat_statements). Helps: Supabase Advisors, and HypoPG to test an index without building it.
- Works on
- Any PostgreSQL host: Supabase, Neon, RDS, Cloud SQL or self-hosted.
Related prompts
- Queries that grow badlyPromptFinds the database queries that will be the first to slow down as tables grow.
- Check time that catches nothingPromptFinds paid automated-check minutes spent on checks that never catch anything.
- Stop rewriting data that hasn't changedPromptUpserts and updates run at high volume, imports are costly, or vacuum and write-ahead log churn look high.
- What will become expensive as the database grows?PromptFact or history tables are growing fast, or you need to plan capacity.
More in Performance and maintenance.