Developers, do you use SQL stored procedures?
-
-
@evan no, I don't want to go looking in multiple places for business logic. Plus, versioning is always a hassle.
-
Stefan Monnierreplied to Evan Prodromou last edited by
@evan By the reactions, I gather that "stored procedures" should be stored with the client rather than with the data, so developers wouldn't to make this silly choice between having to write code-generating code or storing code outside of the application
-
@evan There are circumstances where they are absolutely the right tool for the job.
For example, in a database where the transaction log is correctly implemented (e.g. Postgres, DB2) then using sprocs for complex logic preserves the transaction log as an unpolluted source of truth.
This makes replication (including wide-area async) and recovery vastly easier (and even trivial in some cases). If those properties of the system matter to your use case, sprocs are a good candidate technology.
-
Evan Prodromoureplied to Evan Prodromou last edited by
I'm strong no. In my early career as a developer, the DBA for our Web project insisted on making my team specify and write our own stored procedures, then gave us access only to those stored procedures. I'm doing database systems at graduate school, and I would like to try implementing something non-trivial in stored procedures, such as the basics of an ActivityPub server.
-
Eric Carrollreplied to Evan Prodromou last edited by [email protected]
@evan
Strong, Emphatic no.I once had to deal with a business critical financial processing app implemented *entirely* in stored procedures. Everything but the UI.
Why stored procedures? Because the DBA was the senior dev on the project.
So let me assure you:
1. Yes you can, it's Turing complete
2. You will regret it.It remains the largest crawling horror of my career.