Changeset 106 for devel/_activity

Show
Ignore:
Timestamp:
01/12/06 08:02:45 (3 years ago)
Author:
sven
Message:

some sql optimisation
- count(*) is more efficient than equivalent count(fieldname) of primary key
- unlefting left joins where the right is required
- "a IN (x,y)" is easier to optimise than "a=x OR a=y"

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/_activity/index.php

    r98 r106  
    4040                 
    4141                $activities = db_query("select users.username, weblog_comments.*, weblog_posts.ident as weblogpost, weblog_posts.title as weblogtitle, weblog_posts.weblog as weblog from weblog_comments left join weblog_posts on weblog_posts.ident = weblog_comments.post_id left join users on users.ident = weblog_posts.weblog where weblog_comments.posted >= $starttime and weblog_posts.owner = $page_owner order by weblog_comments.posted desc"); 
    42                 if (sizeof($activities) > 0) { 
     42                if (is_array($activities) && sizeof($activities) > 0) { 
    4343                        foreach($activities as $activity) { 
    4444                                $commentbody = stripslashes($activity->body); 
     
    5959                 
    6060                $activities = db_query("select users.username, users.name as weblogname, weblog_comments.*, weblog_posts.weblog, weblog_posts.ident as weblogpost, weblog_posts.title as weblogtitle, weblog_posts.weblog as weblog from weblog_watchlist left join weblog_comments on weblog_comments.post_id = weblog_watchlist.weblog_post left join weblog_posts on weblog_posts.ident = weblog_comments.post_id left join users on users.ident = weblog_posts.weblog where weblog_watchlist.owner = $page_owner and weblog_comments.posted >= $starttime order by weblog_comments.posted desc"); 
    61                 if (sizeof($activities) > 0) { 
     61                if (is_array($activities) && sizeof($activities) > 0) { 
    6262                        foreach($activities as $activity) { 
    6363                                $commentbody = stripslashes($activity->body);