Updated daily, used by no one
A model that builds green every morning looks alive. It can still be dead. In our 10,000+ model project, hundreds of models were updating on schedule, loading fresh data every day, and feeding nothing anyone needed. This is the method that finds them: not by hunting for what looks dead, but by proving what is alive and questioning everything else. Names are generic; the method and numbers are real. The other half of this cleanup, warehouse objects the code never even mentions, has its own post.
The best-disguised dead weight
An orphaned table at least looks abandoned. A scheduled model is worse: every signal says healthy. The run is green, the timestamps are fresh, the row counts move. It passes every operational check we have, because every operational check measures whether it runs, and none measures whether anyone needs it. Meanwhile it costs more than any dead table: scheduled compute every single day, maintenance whenever something upstream changes, and false confidence for every engineer who assumes that a running model must be running for a reason.
Being loaded and being used are different things. To separate them you have to stop asking "what looks dead?" and ask the opposite question.
Prove what's alive, question the rest
Opt in what's needed
Enumerate the endpoints that legitimately matter: the user-facing layer, plus every other sink that counts as a real consumer. This list is deliberate, written down, and short. Everything else in the project exists only to feed these.
Walk upstream, take the closure
From every endpoint, walk the dependency graph upstream (breadth-first, deduped) and collect everything that directly or indirectly feeds one. That closure is the alive set, by construction. Every model outside it runs for nobody: no path from its output to anything that matters, no matter how green its runs are.
The closure, drawn: everything with a path to an amber endpoint is alive (green). The legacy branch builds green every morning, loads fresh data, and reaches nothing (red): its edges stop before any endpoint.
Attach the lineage to the verdict
A bare list of names gets ignored; nobody retires a model on a string match. So every candidate carries its context: direct parents and children, the size of its downstream closure, and a nested lineage tree, packaged into one workbook with a tab per layer. The person reviewing sees what the model touches without ever opening the manifest, and the retire decision becomes reading, not archaeology.
The 400 went into the same path as the warehouse-side candidates: human review, then soft retirement, nothing dropped outright. Every one of them had been spending compute daily; stopping a schedule is the cheapest optimization there is.
What I learned
- Green runs and fresh data are liveness signals, not usefulness signals. Operational monitoring answers "does it run?"; nothing in it answers "should it?"
- "Needed" is an opt-in list, not a guess. Enumerate the legitimate endpoints and walk upstream; everything else must argue for its life. Getting that list right matters more than the traversal.
- Attach the lineage to the verdict. A bare list of 400 names gets ignored; the same list with parents, children, and downstream trees per row gets acted on.
- The cheapest optimization is the run you stop scheduling. Query tuning saves milliseconds; retiring a pointless daily model saves the whole run, every day, forever.
The dbt implementation
The mechanics, folded away so the story stays short.
What the script reads from the manifest
Everything keys off target/manifest.json, dbt's compiled project graph:
nodes[uid]['depends_on']['nodes']: each model's upstream refs and sources, used to walk the graph in either direction.nodes[uid]['original_file_path']: classifies models by folder layer and detectsinactive/folders.nodes[uid]['schema']/['alias']/['config']: materialization, tags, enabled flag.
A model counts as used only if something refs it in dbt; objects the code never declares are invisible here, which is what the companion post's warehouse diff is for.
The endpoint closure and lineage workbook
The opt-in endpoint set in our project: every user-facing mart model plus every
business-vault model (bv_*). A breadth-first walk over
depends_on from all endpoints builds the alive closure.
For each model outside it, the script records direct upstream and downstream, total
downstream closure size, and a nested JSON lineage tree (diamond joins collapse to a
leaf name so the tree stays finite). Output is one workbook with a tab per layer:
unused load models, unused stage models, and unused intermediate-layer models.