When the number of comment tables grows to a certain extent, it is necessary to add redundant fields. Although there are a few more redundant fields to maintain, the performance improvement is obvious. After all, no one wants the database to be overwhelmed, right?
In addition, the number of likes, comments, and readings are not data with high real-time requirements, so there is no need to update this field every time you like (unlike)/comment (delete a comment)/browse, you can Just write a timed script to update those redundant fields every half hour or hour
The design of the sub-table is correct. When you consider the increase in data volume, a heavy table is not easy to use. This is even more necessary if you consider that there will be additional information later such as likes.
It is recommended to cache and only update the cache in real time. Specific persistence can be run regularly.
When the number of comment tables grows to a certain extent, it is necessary to add redundant fields. Although there are a few more redundant fields to maintain, the performance improvement is obvious. After all, no one wants the database to be overwhelmed, right?
In addition, the number of likes, comments, and readings are not data with high real-time requirements, so there is no need to update this field every time you like (unlike)/comment (delete a comment)/browse, you can Just write a timed script to update those redundant fields every half hour or hour
The design of the sub-table is correct. When you consider the increase in data volume, a heavy table is not easy to use. This is even more necessary if you consider that there will be additional information later such as likes.
It is recommended to cache and only update the cache in real time. Specific persistence can be run regularly.