'MySQL server has gone away without huge data but due to long time
The script takes too much time and so I am getting this error. I will try to optimize it. I want advice, will using, mysql_pconnect is better than mysql_connect in this case? ( http://www.php.net/manual/en/features.persistent-connections.php ) Script is like, connect to database, get all rows that have images missing. download each image using web-service, and update the rows. and at last disconnect mysql. Data of mysql is not huge, but image downloading takes time. And i can't update row before image is not downloaded as by chance image is not downloaded, mysql will have wrong data. what precaution should i take using mysql_pconnect?and is there any mysqli_pconnect?
The site is in developing phase. We were getting apache time out. Hosting provider have increased after our request. Now we are getting this error. It takes over 5 minutes prior but now we changed into batches not doing all at a time. we have to download 100s of images. each property having, 5 to 50 images and daily 10 to 15 properties are new. so, there are so many images. So, answer of how much is depends on how much application can do without any error. now mysql is botterneck. There are 1000 to 2000 rows of rows. that is not huge for mysql and query is
$query = "update ".$property['table_name']." set downloaded_pic_count= '$remaining' where ".$unique."='".$download_pics[$unique]."'";
Solution 1:[1]
Use mysql_ping
before update query. Reconnect if connection lost. Use set_time_limit(0)
for long running scripts.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | zoonman |