Removed user table JOIN from ActiveUsers query.
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 27 Feb 2013 22:47:51 +0000 (14:47 -0800)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 15 Mar 2013 05:34:34 +0000 (05:34 +0000)
Change-Id: I2d6d2154a277d256db09e2a851424ba026862be9

includes/specials/SpecialActiveusers.php

index 20da4a3..c9c82ad 100644 (file)
@@ -97,17 +97,19 @@ class ActiveUsersPager extends UsersPager {
                        $conds[] = 'ipb_deleted IS NULL OR ipb_deleted = 0'; // don't show hidden names
                }
                $conds[] = 'rc_log_type IS NULL OR rc_log_type != ' . $dbr->addQuotes( 'newusers' );
-               $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $dbr->timestamp( wfTimestamp( TS_UNIX ) - $this->RCMaxAge*24*3600 ) );
+               $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes(
+                       $dbr->timestamp( wfTimestamp( TS_UNIX ) - $this->RCMaxAge*24*3600 ) );
 
                if( $this->requestedUser != '' ) {
                        $conds[] = 'rc_user_text >= ' . $dbr->addQuotes( $this->requestedUser );
                }
 
-               $query = array(
-                       'tables' => array( 'recentchanges', 'user', 'ipblocks' ),
-                       'fields' => array( 'user_name' => 'rc_user_text', // inheritance
+               return array(
+                       'tables' => array( 'recentchanges', 'ipblocks' ),
+                       'fields' => array(
+                               'user_name' => 'rc_user_text', // for Pager inheritance
                                'rc_user_text', // for Pager
-                               'user_id',
+                               'user_id' => 'rc_user',
                                'recentedits' => 'COUNT(*)',
                                'ipb_deleted' => 'MAX(ipb_deleted)'
                        ),
@@ -115,16 +117,14 @@ class ActiveUsersPager extends UsersPager {
                                'GROUP BY' => array( 'rc_user_text', 'user_id' ),
                                'USE INDEX' => array( 'recentchanges' => 'rc_user_text' )
                        ),
-                       'join_conds' => array(
-                               'user' => array( 'INNER JOIN', 'rc_user_text=user_name' ),
+                       'join_conds' => array( // check for suppression blocks
                                'ipblocks' => array( 'LEFT JOIN', array(
-                                       'user_id=ipb_user',
-                                       'ipb_auto' => 0
+                                       'rc_user=ipb_user',
+                                       'ipb_auto' => 0 # avoid duplicate blocks
                                )),
                        ),
                        'conds' => $conds
                );
-               return $query;
        }
 
        function formatRow( $row ) {