Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Question about query in statement "Lastup" in includes.inc.php  (Read 2149 times)

0 Members and 1 Guest are viewing this topic.

net

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 88

Hi,

I like to use the "lastup" statement on the fron page, however it does generate quiet the queryload when it scans the entire pictures table.. I've modified the "Lastup" statement, and it's running very much faster for me now, however i'm not a expert so i wish to know what it was i really removed (features or what not)

This is the original code:

Code: [Select]
        case 'lastup': // Last uploads
                if ($META_ALBUM_SET && $CURRENT_CAT_NAME) {
                        $album_name = $lang_meta_album_names['lastup'].' - '. $CURRENT_CAT_NAME;
                } else {
                        $album_name = $lang_meta_album_names['lastup'];
                }

                $query = "SELECT COUNT(*) from {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' $META_ALBUM_SET";
                $result = cpg_db_query($query);
                $nbEnr = mysql_fetch_array($result);
                $count = $nbEnr[0];
                mysql_free_result($result);


                //if($select_columns != '*' ) $select_columns .= ',title, caption, owner_id, owner_name, aid';
                $select_columns = '*'; //allows building any data into any thumbnail caption
                $query = "SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' $META_ALBUM_SET ORDER BY pid DESC $limit";
                $result = cpg_db_query($query);

                $rowset = cpg_db_fetch_rowset($result);
                mysql_free_result($result);

                if ($set_caption) build_caption($rowset,array('ctime'));

                $rowset = CPGPluginAPI::filter('thumb_caption_lastup',$rowset);

                return $rowset;
                break;

I've removed this part:

Code: [Select]
                $query = "SELECT COUNT(*) from {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' $META_ALBUM_SET";
                $result = cpg_db_query($query);
                $nbEnr = mysql_fetch_array($result);
                $count = $nbEnr[0];
                mysql_free_result($result);

From what i can understand (with no real knowledge of sql or php) this query asks the database table pictures if there's any pictures that are private or not accessible? Then the second query asks to sort by and how many to display.

If this is true, i'm all good, however will i loose any other features then private albums?

Thanks for the help!
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Question about query in statement "Lastup" in includes.inc.php
« Reply #1 on: July 23, 2009, 02:47:27 pm »

The query actually "asks" the database if there are any pics that need admin approval. As you have disabled that feature (as per your other, similar request), that query is not doing much. The file in question is not includes.inc.php (such a file doesn't exist), but you're probably refering to include/functions.inc.php.
I can understand that you're keen to "optimize" coppermine's core code, but I can not recommend to go through the code like you do, trying to optimize here and there: if a simple select count is bringing down your server in terms of performance you'd better look for better webhosting than for "optimizations" that you don't fully understand and that you will need to re-apply each time you update coppermine.
Bottom line: find the culprit for bad performance and eliminate it instead of doctoring inside the code.
Logged

net

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 88
Re: Question about query in statement "Lastup" in includes.inc.php
« Reply #2 on: July 23, 2009, 04:35:47 pm »

The query actually "asks" the database if there are any pics that need admin approval. As you have disabled that feature (as per your other, similar request), that query is not doing much. The file in question is not includes.inc.php (such a file doesn't exist), but you're probably refering to include/functions.inc.php.
I can understand that you're keen to "optimize" coppermine's core code, but I can not recommend to go through the code like you do, trying to optimize here and there: if a simple select count is bringing down your server in terms of performance you'd better look for better webhosting than for "optimizations" that you don't fully understand and that you will need to re-apply each time you update coppermine.
Bottom line: find the culprit for bad performance and eliminate it instead of doctoring inside the code.

I do know about this issue, and updating coppermine in the past has been hell due to all the modifications i've made (since i basicly don't understand what changes i really do)

However , i'm now making my own changelog of stuff i'm changing, so i should be able to keep up with the updates of CPG while reading these boards & changelogs..

You've been very helpful Joachim Müller, thanks.
Logged
Pages: [1]   Go Up
 

Page created in 0.021 seconds with 20 queries.