As time goes by, there will be more and more data in the order table. It is necessary to analyze and analyze the data for a month, a quarter or even the past year, such as refund rate, payment rate, and products associated with the order, etc. Related parameters, but the consequences of such a real-time calculation are either timeout or memory overflow. Please use PHP to solve this problem.
As time goes by, there will be more and more data in the order table. It is necessary to analyze and analyze the data for a month, a quarter or even the past year, such as refund rate, payment rate, and products associated with the order, etc. Related parameters, but the consequences of such a real-time calculation are either timeout or memory overflow. Please use PHP to solve this problem.
For the data before the day, it can be collected and processed regularly every day, stored in the database, and the space is changed for time. In this case, the real-time data only needs to be checked for the current day, the efficiency will be much higher, and the pressure on the server will be greatly reduced. It can also be done Cache to prevent users from being stressed by frequent refreshes
This question is very broad and essentially has nothing to do with language, but generally speaking we can start with these two points
Set up an offline database. Your query should be checked in the offline database, not in the main database (whether to export data or be master-slave depends on your specific situation)
For some frequently needed data, design one or more data analysis tables and run them at regular intervals according to the dimensions you need. You only need to run the historical data at the beginning, and then you only need to run the newly generated data. Just do the analysis
Further, you need to introduce some other tools (such as ES, Hadoop, etc.), and even redesign the form of your data analysis-related products
You can create a summary table, write the statistical information into the summary table regularly, and query the summary table directly later. Anyway, the statistical information is in the form of monthly or quarterly
Run the script in cli mode, not fpm
Use the yield keyword in the loop and no additional intermediate variables are generated