PHP code writing directly processes a large amount of data in MySQL, and it becomes stuck

Source: Internet
Author: User
Sometimes it is necessary to independently process a large amount of data in the database. At this time, you can write your own code to process the data, but the execution consumes a lot of resources, basically, all other functions of the website are stuck there and cannot be moved. Do you have any good solutions? The actual situation is like this, public... sometimes it is necessary to independently process a large amount of data in the database. At this time, you can write your own code to process the data, but the execution consumes a lot of resources, basically, all other functions of the website are stuck there and cannot be moved. Do you have any good solutions?

The actual situation is that Company A has telephone recording files, which must be associated with users in system B, the file name of the recording file contains the user's phone number. You can use the phone number to search for the customer ID in the database of system B, and then associate it with a total of tens of thousands of call records. PHP writes a piece of code for processing, but once executed, other functions of the system become stuck and cannot be moved.

Reply content:

Sometimes it is necessary to independently process a large amount of data in the database. At this time, you can write your own code to process the data, but the execution consumes a lot of resources, basically, all other functions of the website are stuck there and cannot be moved. Do you have any good solutions?

The actual situation is that Company A has telephone recording files, which must be associated with users in system B, the file name of the recording file contains the user's phone number. You can use the phone number to search for the customer ID in the database of system B, and then associate it with a total of tens of thousands of call records. PHP writes a piece of code for processing, but once executed, other functions of the system become stuck and cannot be moved.

In this case, most of the results may be caused by SQL statement performance problems. You can try to optimize your SQL statements by referring to the previous article: The best 20 + MySQL performance optimization experience.

I don't know if this is an automatic task or? If it is an automatic task, we recommend that you execute it in the middle of the night when there is a small amount of user traffic. If not, I don't know if it is too many reads or writes? Write too much. You probably have locked the table.

Optimize Your SQL. First, determine the bottleneck? It is generally not in PHP.

When talking to a friend, I suddenly thought that the recording file contains the recording time, and each recording has the corresponding service information submitted to the system, then, you can first collect the time of these Recording files, sort them, retrieve the time period, and then read the user_id of the corresponding service record during the time period, and associate it with the phone number, then perform file operations, which can greatly reduce the frequency of accessing the database.
This is probably the right idea.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.