V
V
vrazbros2021-07-18 16:35:40
MySQL
vrazbros, 2021-07-18 16:35:40

What table structure can be improved to store the client's balance?

At some particular moment, the customer table grew. This table is used in a large number of different processes, for building reports and there are constant changes in it. One of the important elements is the data on the current balance of the client's funds, which is stored in the balance field in the clients table. This field is constantly loaded by parallel requests to get and change its current value. In such situations, there is a risk of simultaneous write-offs from the same balance without taking into account its parallel changes from other processes.
How can the structure of the clients table be improved?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lazy @BojackHorseman MySQL, 2021-07-18
Tag

customer table has grown

This is wonderful
In such situations, there is a risk of simultaneous write-offs from the same balance without taking into account its parallel changes from other processes.

priority queue of account transactions. it is better to be patient with receiving a balance or authorizing a transaction than to shaman blocking (in the financial sense) on the account (you do not write processing) or risk an overdraft. muscle can be destroyed, but this is not a good idea.
and the very probability of a collision on the balance of the account is scanty. the physical act of requesting an account balance or making a transaction on it takes time.

R
Roman Mirilaczvili, 2021-07-20
@2ord

One of the important elements is the data on the current balance of the client's funds, which is stored in the balance field in the clients table. This field is constantly loaded by parallel requests to get and change its current value.
The balance field can be moved to a separate table, then the clients table will not be blocked. Right now there are many reads and writes on the same table. With a separate clients table, it will be almost read-only, and a write-frequent balance table will not block clients requests.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question