More efficient (faster) way to do this mysql update?
Posted: Wed Feb 15, 2012 8:39 am
I have a db of about 500k entries that need to convert a date string (i.e. Apr 11 201 22:37) TO unix time (i.e. 1207971420).
I wrote a script that works completely fine. It's just that it's taking FOREVER! Is there a more efficient way of accomplishing the above? Here's the code:
Thanks for any help!
I wrote a script that works completely fine. It's just that it's taking FOREVER! Is there a more efficient way of accomplishing the above? Here's the code:
Code: Select all
while ($id <= 345441)
{
$query = mysql_query("SELECT * FROM ".$prefix."store_referringurl WHERE id LIKE '$id'");
while ($row = mysql_fetch_assoc($query) )
{
$timeStamp = $row["timeStamp"];
}
$toUT = strtotime("$timeStamp");
mysql_query("update ".$prefix."store_referringurl SET unixTime='$toUT' where id='$id'")or die(mysql_error());
echo"<BR><b>$id</b> updated $timeStamp to <b>$toUT</b><hr>";
$id++;
}