Advanced search  

News:

cpg1.5.24 maintenance release - upgrade recommended
The Coppermine development team is releasing an update for Coppermine in order to fix several minor issues. All fixes are not security critical, so if your gallery is running fine with cpg1.5.20 or cpg1.5.22 you don't need to upgrade. If you are running an older version than cpg1.5.20, you must update to this latest version as soon as possible because of the security impact!
[more]

Pages: [1]   Go Down

Author Topic: [Done]: Try to improve the performance of random pictures show!!  (Read 5999 times)

0 Members and 1 Guest are viewing this topic.

jokera

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 11
    • 那顆爛蔥 專屬相簿

in CPG 1.4.18 functions.inc.php
Line1229:
Code: [Select]
$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:
Code: [Select]
$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

« Last Edit: October 23, 2008, 02:28:21 pm by Nibbler »
Logged

jokera

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 11
    • 那顆爛蔥 專屬相簿
Re: Try to improve the performance of random pictures show!!
« Reply #1 on: July 29, 2008, 07:13:16 pm »

Sorry..I write the wrong title  :P
It should be "of" not "or"  ;)
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Try to improve the performance or random pictures show!!
« Reply #2 on: July 29, 2008, 07:22:53 pm »

Not related to photography, moving accordingly. In the future, use the proper sub-board!
Logged

Nibbler

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 19981
Re: Try to improve the performance or random pictures show!!
« Reply #3 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.
Logged
I don't care about what they say, I won't live or die that way.
Pages: [1]   Go Up
 

Page created in 0.168 seconds with 19 queries.