MySQL thousands of updates, slowing down.

Posted by noryb009 on Stack Overflow See other posts from Stack Overflow or by noryb009
Published on 2010-04-20T23:05:36Z Indexed on 2010/04/20 23:13 UTC
Read the original article Hit count: 206

Filed under:
|
|

I need to run a PHP loop for a total of 100, 000 times (about 10, 000 each script-run), and each loop has about 5 MySQL UPDATES to it. When I run the loop 50 times, it takes 3 sec. When I run the loop 1000 times, it takes about 1300 sec. As you can see, MySQL is slowing down ALOT with more UPDATEs.

This is an example update:

mysql_query("UPDATE table SET `row1`=`row1` +1 WHERE `UniqueValue`='5'");

This is generated randomly from PHP, but I can store it in a variable and run it every n loops.

Is there any way to either make MySQL and PHP run at a consistent speed (is PHP storing hidden variables?), or split up the script so they do?

Note: I am running this for a development purposes, not for production, so there will only be 1 computer accessing the data.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql