Prompt·Schema and dependencies·PG10
Which database objects no longer earn their keep?
The list of views, functions and triggers has grown hard to reason about.
Prompt
Examine the tables, views, functions, triggers, indexes and materialized views in this database. Identify redundant representations, obsolete objects, overlapping responsibilities, unnecessary dependency chains and abstractions that no longer provide meaningful value. Verify actual consumers before recommending removal. Rank opportunities by complexity eliminated, operational savings and migration risk.
- What it returns
- A map of objects, what depends on them and who uses them, the removal candidates, migration risks and how much complexity goes away.
- Skip it when
- The schema is small and every object has a known reader.
- Avoid
- Deleting objects that look unused but are called dynamically or by outside clients.
- Changes
- Changes nothing
- Sessions
- Look first, then fix in a new session
- Tools
- Needs: read-only database access to the catalog, plus the repository and any outside clients.
- Works on
- Any PostgreSQL host: Supabase, Neon, RDS, Cloud SQL or self-hosted.
Related prompts
- Layers that don't earn their keepPromptFinds extra layers of code you could delete so the code, and the agents reading it, get simpler.
- Packages nobody uses, or that work by luckPromptFinds packages nobody uses and packages that work only by accident.
- Find where write logic should livePromptBusiness rules are split across SQL, triggers, edge functions, server routes and workers.
- Are we storing the same truth multiple times?PromptCaches, aggregates, materialized views or derived columns drift from the raw facts.
- Can the schema be easier to understand without losing depth?PromptNew developers or agents keep misunderstanding names, concepts or relationships.
More in Schema and dependencies.