Revert 33072 for now -- changes to ucuserprefix use
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 10 Apr 2008 17:18:27 +0000 (17:18 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 10 Apr 2008 17:18:27 +0000 (17:18 +0000)
Using the user_timestamp index means you can't do an indexed search on the name prefix...
Basically the same as scanning raw on rev_timestamp, but with logged-in edits skipped so you don't scan *quite* as huge an amount of the table.
Since there's no index for the username prefix, the more specific the prefix, the *more* rows you'll have to scan through to fill out the result set, so the worse the performance will get.

includes/api/ApiQueryUserContributions.php

index f0097b1..672c16c 100644 (file)
@@ -62,8 +62,6 @@ class ApiQueryContributions extends ApiQueryBase {
 
                if(isset($this->params['userprefix']))
                {
-                       if(!preg_match('/^\d{1,3}\.\d{1,3}\./', $this->params['userprefix']))
-                               $this->dieUsage("ucuserprefix must contain at least two octets terminated by a period", 'baduserprefix');
                        $this->prefixMode = true;
                        $this->userprefix = $this->params['userprefix'];
                }
@@ -139,13 +137,13 @@ class ApiQueryContributions extends ApiQueryBase {
                $this->addWhereFld('rev_deleted', 0);
                // We only want pages by the specified users.
                if($this->prefixMode)
-               {
-                       $this->addWhere(array('rev_user' => 0));
                        $this->addWhere("rev_user_text LIKE '" . $this->getDb()->escapeLike($this->userprefix) . "%'");
-               }
                else 
                        $this->addWhereFld( 'rev_user_text', $this->usernames );
                // ... and in the specified timeframe.
+               // Ensure the same sort order for rev_user_text and rev_timestamp
+               // so our query is indexed
+               $this->addWhereRange('rev_user_text', $this->params['dir'], null, null);
                $this->addWhereRange('rev_timestamp', 
                        $this->params['dir'], $this->params['start'], $this->params['end'] );
                $this->addWhereFld('page_namespace', $this->params['namespace']);
@@ -270,10 +268,7 @@ class ApiQueryContributions extends ApiQueryBase {
                        'start' => 'The start timestamp to return from.',
                        'end' => 'The end timestamp to return to.',
                        'user' => 'The user to retrieve contributions for.',
-                       'userprefix' => array(
-                               'Retrieve contibutions for all IP addresses that begin with this value.',
-                               'Overrides ucuser. Must contain at least two octets terminated by a period'
-                       ),
+                       'userprefix' => 'Retrieve contibutions for all users whose names begin with this value. Overrides ucuser.',
                        'dir' => 'The direction to search (older or newer).',
                        'namespace' => 'Only list contributions in these namespaces',
                        'prop' => 'Include additional pieces of information',