• by PaulHoule on 9/30/2020, 6:05:20 PM

    Today many devs build a "service layer" that exposes an API that covers up the database. Somebody might write that in Java, Node.js, .NET, etc. or they could implement it in stored procedures.

    If a transaction BEGINs and ENDs in the stored proc, you eliminate a huge amount of waiting time in which a tx could conflict with another tx. A tx inside the database can't possibly mutate some global state which makes it no longer be a tx. Presumably some SQL expert writes the stored proc and they've got a better chance of getting the details right, etc.

    There are toolkits for managing stored procedures in version control and stored procedures can be highly productive for coding certain things. I've worked on Microsoft SQL Server projects that used lots of stored procs and thought we were doing OK.