Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.822
diff -u -p -r1.822 comment.module
--- modules/comment/comment.module	26 Dec 2009 16:50:08 -0000	1.822
+++ modules/comment/comment.module	28 Dec 2009 09:17:20 -0000
@@ -1520,23 +1520,19 @@ function comment_load($cid) {
  * special handling for comment objects.
  */
 class CommentController extends DrupalDefaultEntityController {
-  protected function buildQuery() {
-    parent::buildQuery();
-    // Specify additional fields from the user and node tables.
-    $this->query->innerJoin('node', 'n', 'base.nid = n.nid');
-    $this->query->addField('n', 'type', 'node_type');
-    $this->query->innerJoin('users', 'u', 'base.uid = u.uid');
-    $this->query->addField('u', 'name', 'registered_name');
-    $this->query->fields('u', array('uid', 'signature', 'picture', 'data'));
-  }
-
   protected function attachLoad(&$comments) {
     // Setup standard comment properties.
+    // To avoid joining on the {node} table, get the node type from the node
+    // itself. node_load() will be statically cached nearly every time comments
+    // are loaded so this is usually cheaper than either a join or a separate
+    // query.
+    $comment = reset($comments);
+    if ($comment) {
+      $node = node_load($comment->nid);
+    }
     foreach ($comments as $key => $comment) {
-      $comment = drupal_unpack($comment);
-      $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
       $comment->new = node_mark($comment->nid, $comment->changed);
-      $comment->node_type = 'comment_node_' . $comment->node_type;
+      $comment->node_type = 'comment_node_' . $node->type;
       $comments[$key] = $comment;
     }
     parent::attachLoad($comments);
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.1095
diff -u -p -r1.1095 user.module
--- modules/user/user.module	26 Dec 2009 16:50:09 -0000	1.1095
+++ modules/user/user.module	28 Dec 2009 09:17:21 -0000
@@ -3024,6 +3024,24 @@ function user_node_load($nodes, $types) 
 }
 
 /**
+ * Implements hook_comment_load().
+ */
+function user_comment_load($comments) {
+  // Build an array of all uids for comment authors, keyed by uid.
+  foreach ($comments as $cid => $comment) {
+    $uids[$cid] = $comment->uid;
+  }
+  $user_fields = db_query("SELECT uid, name, picture, signature, data FROM {users} WHERE uid IN (:uids)", array(':uids' => $uids))->fetchAllAssoc('uid');
+  foreach ($uids as $cid => $uid) {
+    $comments[$cid]->name = $cid ? $user_fields[$uid]->name : $comments[$cid]->name;
+    $comments[$cid]->picture = $user_fields[$uid]->picture;
+    $comments[$cid]->signature = $user_fields[$uid]->signature;
+    $comments[$cid]->data = $user_fields[$uid]->data;
+    drupal_unpack($comments[$cid]);
+  }
+}
+
+/**
  * Implements hook_image_style_delete().
  */
 function user_image_style_delete($style) {
