Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use complex SQL queries or process results in the application?

I am dealing with an application with huge SQL queries. They are so complex that when I finish understanding one I have already forgotten how it all started.

I was wondering if it will be a good practice to pull more data from database and make the final query in my code, let's say, with Python. Am I nuts? Would it be that bad for performance?

Note, results are huge too, I am talking about an ERP in production developed by other people.

like image 341
n3storm Avatar asked Feb 03 '23 14:02

n3storm


1 Answers

Let the DB figure out how best to retrieve the information that you want, else you'll have to duplicate the functionality of the RDBMS in your code, and that will be way more complex than your SQL queries.

Plus, you'll waste time transferring all that unneeded information from the DB to your app, so that you can filter and process it in code.

All this is true because you say you're dealing with large data.

like image 178
Roshan Mathews Avatar answered Feb 05 '23 06:02

Roshan Mathews