# Aggregate Operations Solutions (Continued...)

+ The data in the table is update frequently
  + Implementation of statistical tables
    + Simple design
    + Suitable for situations where data is not highly time-sensitive
  + Using cache counters
    + The real-time performance is better
    + Need to introduce a caching mechanism such as**Redis**, which is prone to inconsistencies with database data
------------------------------------------------------------
In the second case, if our table DML is frequent, the following two optimizations are recommended:

1. Using a statistical table, if the timeliness of statistical data is not high, the statistical results can be put into the statistical table after regular statistics are carried out. Subsequent request directly query the results from the statistical table, so as to avoid the risk of multiple concurrent detailed tables for concurrent count and crushing the database. The advantages of this solution are: simple architecture and implementation, disadvantages are: timeliness is not high

2. Use cache counters, such as those of Redis, and update the cache counters after each database data is written, so that you can directly cache the query results. The advantages of this solution are that the results are relatively accurate, and the disadvantage is that there may be inconsistencies between the cache and the DB, and the introduction of Redis, and the architecture is relatively complex.
