coppermine-gallery.com/forum

No Support => Feature requests => Scheduled for cpg1.5.x => Topic started by: jokera on July 29, 2008, 07:02:56 PM

Title: [Done]: Try to improve the performance of random pictures show!!
Post by: jokera on July 29, 2008, 07:02:56 PM
in CPG 1.4.18 functions.inc.php
Line1229:

$query = "SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' $META_ALBUM_SET ORDER BY RAND() LIMIT $limit2";
$result = cpg_db_query($query);

Change to:

$queryrndlimit = "SELECT `pid` FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' $META_ALBUM_SET ORDER BY RAND() LIMIT $limit2";
$rndlimitresult = cpg_db_query($queryrndlimit);
$pidstring="(0";
while($pidtemp=mysql_fetch_array($rndlimitresult)){
    $pidstring.=",".$pidtemp['pid'];
}
$pidstring.=")";
$query = "SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} WHERE `pid` in $pidstring";
$result = cpg_db_query($query);


In my site:(Total 566xx pictures)
Original method : 12~14 seconds
New method : 0.23~0.4 seconds

Title: Re: Try to improve the performance of random pictures show!!
Post by: jokera on July 29, 2008, 07:13:16 PM
Sorry..I write the wrong title  :P
It should be "of" not "or"  ;)
Title: Re: Try to improve the performance or random pictures show!!
Post by: Joachim Müller on July 29, 2008, 07:22:53 PM
Not related to photography, moving accordingly. In the future, use the proper sub-board!
Title: Re: Try to improve the performance or random pictures show!!
Post by: Nibbler on July 29, 2008, 07:40:44 PM
We should add this to 1.5. It will help with the 'Got error 28 from table handler' issue too.