A
A
Albert Ushakov2021-05-16 10:12:47
PHP
Albert Ushakov, 2021-05-16 10:12:47

Which way to calculate the amount in the database is better and more promising for a large volume?

The question seems to be simple, but I have not yet understood and have not found an answer for myself.
We have, for example, a database of, for example, several tens of millions of records.
And in each entry, a random number up to 10k.
How actually it is better to calculate the sum of these numbers and with a smaller load?
On the php side in the loop or on the sql side in the query itself?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ivan Shumov, 2021-05-16
@fuck_ask

Stop doing bullshit and start storing aggregates in the database

R
Rsa97, 2021-05-16
@Rsa97

Naturally, in SQL.

D
d-stream, 2021-05-16
@d-stream

Let's complicate the question: the base lives on a separate server, the channel to which is 1 Mbps and we will try to answer the original question in such conditions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question