r/FullStack • • 21d ago

Question Why implement procedural programming inside an RDBMS (MariaDB) instead of handling all business logic in backend application code?

So I have just seen the procedural programming language in the MariaDB RDBMS. So my question is, why in a relational database management system would you need SQL to also have the power of a programming language? Why in the layer of the database server would you need that? Can that be achieved with your backend server logic programming language, whether it be JavaScript, PHP, Python, Rust, Go, etc.? Why is there a programming language, why SQL is a programming language more so than just for querying and interacting with a database or databases? How does that fit into the full picture of full stack web development?

Edit: Thank you everyone for the thoughtful responses, technical insights, and feedback. All of this input is extremely helpful much appreciated!

17 Upvotes

41 comments sorted by

View all comments

Show parent comment

1

u/MilkEnvironmental106 20d ago

There is also the cost of transporting large amounts of data between a dB and the backend node. Queries on large data usually run much better on the dB where it has access to indexes and metadata and it avoids the network trip completely. It really just depends on whether it's something the query interface of your dB does well.

1

u/Ronin-s_Spirit 20d ago

I don't know what you mean, you still have to return the data to your main logic program unless you've made the strange decision of letting the DB send data straight to the user.

I'm assuming the DB lives on another server, because otherwise there are almost zero benefits to running code inside the DB.

1

u/MilkEnvironmental106 19d ago

I'm talking about large aggregation queries and sending the entire dataset and processing Vs aggregating on the server and sending the aggregated response.

1

u/BigFeeder 19d ago

No application that works beyond couple of hundred database rows aggregates data on server side

1

u/MilkEnvironmental106 19d ago

Okay, well applications that work on less than a couple hundred of rows are small fish in a very big pond...