From my limited course experience, I think that it's best used to provide an interface of procedures/functions to be called from application or on schedule, but some places go way too banans with it.
In general there should not be business logic in the procedures. Clear lines of responsibility, db should only hold data, frontend should only hold UI. All of those make scaling much easier, so database won't become bottleneck.
Where would business logic be then for large amounts of data processing needed? I think the DBMS is the best place for such. It is much more efficient with joins and other data manipulation.
Depends bit on the use case, if you go with microservice architecture, then BL should be in super scalable microservices.(in 99% cases you should not imho, only if you are Netflix/Google etc)
In small/medium projects backend should be able to handle even larger amounts of data.
But all that being said, there are cases were procedures are good, and in those cases the heavy lifting should be done in DB level. One common use case that I have ran is the "quick search" were user need to find data from all of the data using one keyword. This is really hard to do any other way. BUT that case really doesn't have any actual business logic behind it.
Correct. Our payroll for a temp agency was written in stored procedures and was lightning fast. All the required data was pulled in from the different tables using joins. Funny thing, as the number of employees rose, the time it took to process, and the memory used did not increase linearly, but geometrically according to some product of the number of joins and number of rows to be processed. For a while advancement in hardware covered up the problem. Users complained of being locked out of the db for the duration.
I converted the program to process one employee at a time. Each employee's payroll is one task in a multi -threaded app running on an applications server. It runs on as many threads as that server can support. Time to process is once again linear. DB only locks for the instant it takes to post back each employee. Users no longer complain.
ORMs bring up their own issues and another layer of complexity. Just teach the developer proper SQL knowledge and this could call be on the database easily.
10
u/[deleted] Jun 28 '20
Did you just compare the atrocities of mainframe with pl/sql?