As time goes on, the list of data in the order table will be more and more, it will need to one months or a quarter or even nearly a year of data analysis statistics, such as the refund rate, payment rate, as well as the products associated with the order related parameters, but such a real-time calculation of the consequences of either a timeout, or memory overflow, Ask for such a problem with PHP solution.
Reply content:
As time goes on, the list of data in the order table will be more and more, it will need to one months or a quarter or even nearly a year of data analysis statistics, such as the refund rate, payment rate, as well as the products associated with the order related parameters, but such a real-time calculation of the consequences of either a timeout, or memory overflow, Ask for such a problem with PHP solution.
For the data before the day, can be collected and processed daily, stored in the database, space for time, so that the real-time data also only need to check the day, the efficiency will be much higher, the pressure on the server will be greatly reduced, you can also do a cache to prevent frequent user refresh pressure
The problem is broad and essentially not related to language, but in general it can start at two.
Set up an offline library, your query to go offline library check, do not go to the main library to query (by exporting data or the decision depends on your specific situation)
For some often needed data, design one or more data analysis tables, according to the dimensions you need to run once, the historical data as long as the beginning of the run is good, after you only need to run the new data to analyze
There is a further need to introduce some other tools (such as ES, Hadoop, etc.) and even to redesign the shape of your data analysis-related products
You can set up a summary table, the statistical information is written into the summary table, and then directly query the summary table, anyway, statistics is the form of the month or quarter
Run the script in CLI mode, do not FPM
The yield keyword is used in the loop, and no extra intermediate variables are generated