Can anyone confirm how many queries are being used to select and display comments, and if it is anywhere near 10 per comment, I suggest this is the next area to be optimised! I can't believe it is that high, but I don't want to take any chances.
Example here - 54 queries counted, just 3 comments
Looking at this function in story.php, it seems to be selecting all comment_ids for a particular story, then doing a $comment->read() on every comment id selected. Then there are child comments too....
Code:
function get_comments (){
Global $db, $main_smarty, $current_user, $CommentOrder, $link;
//Set comment order to 1 if it's not set in the admin panel
if(!isset($CommentOrder)){$CommentOrder = 1;}
If ($CommentOrder == 1){$CommentOrderBy = "comment_votes DESC, comment_date DESC";}
If ($CommentOrder == 2){$CommentOrderBy = "comment_date DESC";}
If ($CommentOrder == 3){$CommentOrderBy = "comment_votes DESC, comment_date ASC";}
If ($CommentOrder == 4){$CommentOrderBy = "comment_date ASC";}
// get all parent comments
$comments = $db->get_col("SELECT comment_id FROM " . table_comments . " WHERE comment_link_id=$link->id and comment_parent = 0 ORDER BY " . $CommentOrderBy);
if ($comments) {
require_once(mnminclude.'comment.php');
$comment = new Comment;
foreach($comments as $comment_id) {
$comment->id=$comment_id;
$comment->read();
$comment->print_summary($link);
// get all child comments
$comments2 = $db->get_col("SELECT comment_id FROM " . table_comments . " WHERE comment_parent=$comment_id ORDER BY " . $CommentOrderBy);
if ($comments2) {
echo '<div style="margin-left:40px">';
require_once(mnminclude.'comment.php');
$comment2 = new Comment;
foreach($comments2 as $comment_id) {
$comment2->id=$comment_id;
$comment2->read();
$comment2->print_summary($link);
}
echo "</div>\n";
}
}
}
}






Linear Mode




