There s a problem in fintech project. We count balance by summarising orders and this approach is too slow. We have an idea:
- to use structure like hash map of stacks to store users balance. As key we use
user_idin our system and stack is filled with transactions and their affection on balance - Each transaction we count new users balance and add it in hash map we declared at 1st step
However there’s some problems. If we store data like this in SQL DB we have query like where user_id = ?1 and take last index which is not effective. Of course we can store our log table in NoSQL DB but it seems to be bad practice in fintech projects. Please give us some ideas or alternative approaches