=== modified file 'modules/forum/forum.module'
--- modules/forum/forum.module	2010-10-03 00:41:14 +0000
+++ modules/forum/forum.module	2010-10-05 21:24:11 +0000
@@ -872,7 +872,21 @@
   }
 
   $query = db_select('forum_index', 'f')->extend('PagerDefault')->extend('TableSort');
-  $query->fields('f');
+
+  $query->join('node', 'n', 'n.nid = f.nid');
+  $query->join('node_comment_statistics', 'ncs', 'n.nid = ncs.nid');
+  $query->join('users', 'u', 'n.uid = u.uid');
+  $query->join('users', 'u2', 'ncs.last_comment_uid = u2.uid');
+
+  $query
+    ->fields('f')
+    ->fields('n', array('title', 'nid', 'type', 'sticky', 'created', 'uid'))
+    ->fields('ncs')
+    ->fields('u', array('name'))
+    ->addField('n', 'comment', 'comment_mode');
+  $query->addField('f', 'tid', 'forum_tid');
+  $query->addExpression("CASE ncs.last_comment_uid WHEN 0 THEN ncs.last_comment_name ELSE u2.name END", 'last_comment_name');
+
   $query
     ->condition('f.tid', $tid)
     ->addTag('node_access')
@@ -888,16 +902,6 @@
 
   $query->setCountQuery($count_query);
   $result = $query->execute();
-  $nids = array();
-  foreach ($result as $record) {
-    $nids[] = $record->nid;
-  }
-  if ($nids) {
-    $result = db_query("SELECT n.title, n.nid, n.type, n.sticky, n.created, n.uid, n.comment AS comment_mode, ncs.*, f.tid AS forum_tid, u.name, CASE ncs.last_comment_uid WHEN 0 THEN ncs.last_comment_name ELSE u2.name END AS last_comment_name FROM {node} n INNER JOIN {node_comment_statistics} ncs ON n.nid = ncs.nid INNER JOIN {forum} f ON n.vid = f.vid INNER JOIN {users} u ON n.uid = u.uid INNER JOIN {users} u2 ON ncs.last_comment_uid = u2.uid WHERE n.nid IN (:nids)", array(':nids' => $nids));
-  }
-  else {
-    $result = array();
-  }
 
   $topics = array();
   foreach ($result as $topic) {

