PHP order data analysis problem

WBOY
Release: 2023-03-02 07:14:01
Original
1577 people have browsed it

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.

Reply content:

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

  1. 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)

  2. 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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!