Answer the question
In order to leave comments, you need to log in
What is the correct way to count a dynamic value?
There is a table of clients, orders and payments. Now clients have a "debt" field. Previously, orders also had it, but it was changed to dynamically calculated. Performance is generally normal, there is not much data.
I would like to do the same with the client's debt. On the move, you can do this: for each client, orders and payments to them (if any) are selected, a calculation is made using group by and sum. In principle, the selection of clients occurs only in the admin panel with a maximum of 200 lines. In other cases, the client's sample will be the only one.
I know that the approach is more labor-intensive, but the field that needs to be updated after each change in the debt in orders (or even the amount of the order) requires a lot of attention.
There is also an approach with updating the field every n times. But not the scale.
Is it normal to drink like that?
Answer the question
In order to leave comments, you need to log in
If the load is insignificant, this is a normal option, so as not to complicate the logic of a simple application.
Usually they do the opposite:
First, they do something dynamically calculated, and when such a calculation becomes a costly operation, they remake it into a register.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question