Better HN
topnewbestaskshowjobs
Log inSign up

twellborn

1 karma · joined Sep 21, 2026 (2mo ago) · 4 submissions

SQL data engineer. I build small tools on the side; latest is orphanmap.com, a read-only dependency mapper for inherited SQL Server boxes.
Submissions

comment 2mo ago · link · parent

It's common and I've observed it in three different industries. The reason it begins is reasonable: the proc is the only stage at which a change can be deployed without going through a release cycle, so all the hotfixes end up there, and after ten years the hotfixes make up the entire system. The circular calls arise for the same reason. Since no one dares to modify proc A, they write proc B which calls proc A and alters its output, and then someone does the same thing to proc B. The deadlocks appear once each of the proc's authors has a different view on where the transaction should start.

comment 2mo ago · link · parent

20 years doing this, including tooling that parses stored procs out of systems nobody fully understands anymore, and I don't think sprocs are the problem people think they are. Where they go wrong is time, not technology.

A well-versioned, well-owned sproc estate today can still be unreadable in 10-15 years, not because the language is bad, but because nothing tracks the drift: the author leaves, the ticket explaining a weird CASE branch gets closed and forgotten, someone patches around a bug three teams away, and now you've got T-SQL nobody currently employed fully understands, with git blame pointing at people who don't work there and comments referencing tickets that don't resolve. That's not a stored-procedure problem, it's an "institutional knowledge decays and nothing makes that visible" problem. It happens to application code too, just slower, since app code at least throws stack traces.

The thing that makes sprocs worse: they stay syntactically correct and keep answering queries even after the business meaning underneath drifts, because there's no compiler error for "this no longer matches reality." I regularly find procs whose own header comment describes something the code three lines below no longer does. Nothing broke. It just quietly returned a slightly wrong number until someone looked.