If the amount of data per day is not particularly large, you can divide the tables by month, so that the problem only needs to be queried and counted in one table;
Use views to create multi-table views, but if the amount of data is large, it will take a long time.
In the case of large amounts of data, relational databases are not a good choice just for recording statistics. You can consider NoSQL, such as Hbase.
= =
MySQL data tables cannot be built infinitely. What is your design? . .
It is recommended to go home and read a book on database design first. . .
If we put them all in one table from the beginning, it wouldn't be so painful at all, right? ? ?
Have you considered performance and maintainability issues? ? ?
The log record table is designed in such a way that frequent insertions will lock the query operation. In Linux, you can write a shell script to count pv visits.
Actually, I think depending on the user scenario, if the data in a day is really millions of rows, creating tables in different days is not necessarily a bad decision.
= =
MySQL data tables cannot be built infinitely. What is your design? . .
It is recommended to go home and read a book on database design first. . .
If we put them all in one table from the beginning, it wouldn't be so painful at all, right? ? ?
Have you considered performance and maintainability issues? ? ?
Try creating a view with multiple tables
select count(1) from pv_150506
union all
select count(1) from pv_150507
union all
........
foreach result set, summed up.
Create a data table every day? Are you crazy
Let’s assume that he automatically creates tables on a monthly basis, and each table has a lot of data
Search like this
When querying, join the tables and merge the query
Dynamically generate query statements
This expression is also earth-shattering
The log record table is designed in such a way that frequent insertions will lock the query operation. In Linux, you can write a shell script to count pv visits.
Brother, was this built under the guidance of sub-table thinking?
Actually, I think depending on the user scenario, if the data in a day is really millions of rows, creating tables in different days is not necessarily a bad decision.