Real-time changes (daily) data comes from queries of a large amount of data, resulting in loading of real-time changes (daily) data from queries of a large amount of data, resulting in loading takes a long time, ask how to optimize
For example, in the user table, A user A invited many members such as A1, A2, a3 .............. an, member A1 invited many members A11, A12, a13 ......... a1n
A2 invited many members A21, A22, A23, and so on, a3 and other indirect members include A11, a21 ..... a21, a22 ..... when each member consumes the service, the member will receive the rebate and at the same time give the superior a portion of the money, and insert the relevant data into the order table, if a user receives a rebate from a relevant member and cannot withdraw the cash within 7 days, the user will be frozen. Therefore, a large amount of data needs to be queried when the account is frozen, including orders consumed by the member within 7 days, we also need to find all direct and indirect members from the user table and then find out their consumption within 7 days, so freezing funds will be very slow to display on the page, ask how to design and optimize the table structure or how to design and optimize the program to accelerate the speed.
Reply to discussion (solution)
As long as there is no subordinate invitation to superiors, such as A22 invited
You can use the pre-order traversal (left-right pre-sorting) algorithm to organize data.
As long as there is no subordinate invitation to superiors, such as A22 invited
You can use the pre-order traversal (left-right pre-sorting) algorithm to organize data.
There will be no lower-level invitations to superiors. could you give me a detailed explanation?
Do not load data in real time during scheduled data updates. this part of operation is processed by an independent server.
There are many introductions on the internet. you can search for them yourself.
What this article says is still clear http://blog.csdn.net/yaerfeng/article/details/8517479
Do not load data in real time during scheduled data updates. this part of operation is processed by an independent server.
If there is consumption every day and the number of regular updates is relatively large, the data will be inaccurate between one scheduled time and the next scheduled time.
Pre-processing does not involve real-time statistics and computation. if data is too big, real-time computation requires you to plan it before you worry about it.
The simplest method is to add fields to the table, record the user IDs at the next layer, and separate them with commas. This reduces the number of queries.