Requirement background group table group chat record table is sharded by month, for example, the region table structure chatTimemessage time groupID group ID requirement description is given a time period, such as the last 7 days of the current day when... requirement background group table
Group
Chat record table
Table sharding by month, such
Chat_message_2015_04
Chat_message_2015_05
Chat_message_2015_06
Table structure
ChatTime // message time
GroupID // group ID
Requirement description
- Specify a time period, for example, the current day, the last 7 days, the current month, and the latest month ~ , Count the number of messages of each group in a given period of time
- Sort the group and output it by page based on the number of statistics.
Reply content: requirement background group table
Group
Chat record table
Table sharding by month, such
Chat_message_2015_04
Chat_message_2015_05
Chat_message_2015_06
Table structure
ChatTime // message time
GroupID // group ID
Requirement description
- Specify a time period, for example, the current day, the last 7 days, the current month, and the latest month ~ , Count the number of messages of each group in a given period of time
- Sort the group and output it by page based on the number of statistics.
1,UNION
2. if innodb sub-tables are used, merge can be used for processing.
Directly create a summary table for statistics
If possible, do not use the table sharding design. in this way, no special processing is required for queries. If you plan the index, the performance should be normal.