Multi-tiered development and business rule

1

I work with a team developing an ERP and I am responsible for issuing reports, one of which executes a select in the bank that in tests took more than 2 hours running, which led to errors and a big doubt: who was processing all the information? " This is where the problem started because the processing is not done by the webserver application but by the database (in this case PostgreSQL).

Correct is to perform all possible calculations directly in the SQL query (seeing that all functions for calculations are in the database itself) or just fetch the database's primitive data and perform all operation via code by the server layer ?

If they have references it is of paramount importance.

    
asked by anonymous 26.11.2018 / 19:53

1 answer

1

It depends. If the data are all in the database and it makes sense to run there to give smaller results, it is relatively simple to do them, so you should do there, otherwise if the most important is to get the raw data where everyone will be needed in the report, the calculations are secondary then you should do in the application.

There is no magic, no cake recipe. I know that nowadays many people who work in IT think that it is just decorating some rules, some solutions and everything is solved. and that was true we would be starting to run out of jobs soon. To know the right answer of this depends on a lot of experience, deep knowledge of computing and understand all the details of the context to give a definitive answer. In fact, not so definitive, just as long as the same criteria and volumes last.

It is not a question of where it is done, but how it is done. It is almost certain that it should not take 21 hours, it is most likely done wrongly and the correct solution is not to decide where to do, is to take less time. There you have a series of techniques to reduce this time, you need to analyze the query (s) to find out where bottlenecks are occurring, and there understanding the operation of the database, changing the queries, the configurations to meet the demand of this case , without disturbing other cases. It's simple? Of course not, so we have jobs and we earn well.

From what you're saying it seems like it will not even make a difference where you're running, but it could be wrong speculation from me because of the lack of question information.

Just remembering that calculation itself is often a tiny part of the processing, the pattern of data access is usually much worse, especially me reports.

In some cases the available hardware is not suitable and causes extreme slowness.

There are scientific methods of observing occurrences to isolate the problem, eliminate the interference, focus on the specific problem, and find the root cause, but this is a general scope and not an infrastructure development or operation.

In some cases it is the fault of existing modeling. What else happens is that people do not understand the power of the index (in others the problem is the abuse of them ).

    
26.11.2018 / 20:12