Author Topic: Optimization & global.php  (Read 3634 times)

0 Members and 1 Guest are viewing this topic.

Offline Cyrille

  • Pre-Newbie
  • Posts: 6
    • View Profile
Optimization & global.php
« on: November 16, 2005, 05:49:53 PM »
Hi,

Does anyony can tell me why there is this request in global.php :
Quote
  $new_cutoff = time() - (60 * 60 * 24 * $config['new_cutoff']);
  $sql = "SELECT c.cat_id, c.cat_name, c.cat_description, c.cat_parent_id, c.cat_hits, c.cat_order, c.auth_viewcat, c.auth_viewimage, c.auth_download , c.auth_upload, c.auth_directupload, c.auth_vote, c.
auth_sendpostcard, c.auth_readcomment, c.auth_postcomment, COUNT(i.image_id) AS new_images
          FROM ".CATEGORIES_TABLE." c
          LEFT JOIN ".IMAGES_TABLE." i ON ( i.cat_id = c.cat_id AND i.image_date >= $new_cutoff AND i.image_active = 1)
          GROUP BY c.cat_id
          ORDER BY c.cat_order, c.cat_name ASC";

        $result = $site_db->query($sql);

This request is VERY slow (2seconds) and run on every webpage.

I replaced this request by : select * from global
As Global a new table and I write in global table every hour,
A now all my webpage are generated in less the 1sec

Cyrille





Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Optimization & global.php
« Reply #1 on: November 17, 2005, 01:09:39 AM »
And now you have no information about how many new images in a sertain category.
That query was also counting that.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)