Let’s imagine that we have an electronic payment system with the database table operations. For example, we want to calculate the size of average operation. It is easy, here's a query:
SELECT avg(amount) FROM transfer;
generated in 3850 seconds
Now let’s imagine that the index should be the latest one, the entries are made every second in the table, and after a month there are millions of them. To aggregate the same data each time is very expensive. Traditional databases do not offer such optimizations. What to do?