We are trying to upgrade from 5.14 to 5.62 and seem to be encountering a bug. We ahve over 20 GB of photos in our database. Our gallery can be found at
http://gallery.off-road.com/photobb/ . Here is the details:
We are in the process of upgrading our PhotoPost 5.14 to the latest version, 5.61.
We have an enormously large, over 20 Gigabyte, PhotoPost managed photo gallery.
We're encountering an incredibly long upgrade in the upgrade 5.5 -> 5.6 portion, and what I'm experiencing is that the database is repeatedly doing the same thing over and over again, wasting time and not really accomplishing anything:
Here's the code from the upgrade.php file I'm talking about
:
$resulta = mysql_query("SELECT userid FROM {$pp_db_prefix}photos WHERE userid > 0", $link);
while ( list( $puser ) = mysql_fetch_row($resulta) )
{
$resultb = mysql_query("SELECT id,user,date FROM {$pp_db_prefix}photos WHERE userid=$puser ORDER BY date DESC LIMIT 1", $link);
while ( list( $pid, $pname, $pdate) = mysql_fetch_row($resultb) )
{
$resultc = mysql_query("SELECT userid FROM {$pp_db_prefix}users WHERE userid=$puser LIMIT 1", $link);
list ( $checkid ) = mysql_fetch_row($resultc);
if ( $checkid )
{
$resultd = mysql_query("UPDATE {$pp_db_prefix}users SET lastphoto=$pid,lastdate=$pdate WHERE userid=$puser", $link);
}
else
{
$pname = addslashes($pname);
$resultd = mysql_query("INSERT INTO {$pp_db_prefix}users (userid,username,lastphoto,lastdate) VALUES ($puser,'$pname',$pid,$pdate)", $link);
}
}
}
print "<br />Upgrade complete! You should continue to <a href=\"upgrade.php?upgrade=56\">next step</a>";
print "</td></tr></table></td></tr></table>";
exit;
I think that the first select statement in the above code snippet needs to be optimized from:
SELECT userid FROM {$pp_db_prefix}photos WHERE userid > 0
to:
SELECT distinct userid FROM {$pp_db_prefix}photos WHERE userid > 0
As we have hundreds of thousands of rows in our photos table, with almost all of them with the same userid, so it keeps updating the same userid over and over and over again.
Do you concur that this is an appropriate bug fix?