search

Home  >  Q&A  >  body text

php - How to split large batches of data?

Hello everyone, there are 10,000 orders in the database, and various calculations need to be performed on the orders every day. The language used is php mysql. Because so much order data was not considered in the previous design, I used a very conventional method of writing and updating all the data to the database and then returning the results. As a result, the checkout process is now stuck on that page, and it takes a long time to complete. Sometimes PHP times out and returns a blank page. Is there any way to prevent PHP from timing out?

Is it possible to divide the order into a group of 100 for processing?

How to achieve this kind of processing of a group of 100, wait a few seconds, and process the next group?

thank you all!

女神的闺蜜爱上我女神的闺蜜爱上我2792 days ago1050

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-06-24 09:43:39

    It is recommended to run batch calculations asynchronously in the background, store the results, and then read the results on the front end

    reply
    0
  • 天蓬老师

    天蓬老师2017-06-24 09:43:39

    
    set_time_limit(0);//防止超时
    
    为订单加上个status位标记是否已经处理,开启后台进程定时跑订单任务

    reply
    0
  • Cancelreply