r47037 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47036‎ | r47037 | r47038 >
Date:14:07, 9 February 2009
Author:catrope
Status:deferred
Tags:
Comment:
API: Fix up r46825:
* put the tables in the right order
* JOIN on user_text as well for better index usage
* Force the index on the recentchanges table as well
* Don't ORDER BY rev_user_text if it's constant
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryUserContributions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryUserContributions.php
@@ -141,8 +141,7 @@
142142 // We're after the revision table, and the corresponding page
143143 // row for anything we retrieve. We may also need the
144144 // recentchanges row.
145 - // Tables have to be in this order for STRAIGHT_JOIN
146 - $this->addTables(array('revision', 'page'));
 145+ $tables = array('page', 'revision'); // Order may change
147146 $this->addWhere('page_id=rev_page');
148147
149148 // Handle continue parameter
@@ -169,7 +168,8 @@
170169 // ... and in the specified timeframe.
171170 // Ensure the same sort order for rev_user_text and rev_timestamp
172171 // so our query is indexed
173 - $this->addWhereRange('rev_user_text', $this->params['dir'], null, null);
 172+ if($this->multiUserMode)
 173+ $this->addWhereRange('rev_user_text', $this->params['dir'], null, null);
174174 $this->addWhereRange('rev_timestamp',
175175 $this->params['dir'], $this->params['start'], $this->params['end'] );
176176 $this->addWhereFld('page_namespace', $this->params['namespace']);
@@ -187,7 +187,7 @@
188188 $this->addWhereIf('rc_patrolled != 0', isset($show['patrolled']));
189189 }
190190 $this->addOption('LIMIT', $this->params['limit'] + 1);
191 - $this->addOption('USE INDEX', array('revision' => 'usertext_timestamp'));
 191+ $index['revision'] = 'usertext_timestamp';
192192
193193 // Mandatory fields: timestamp allows request continuation
194194 // ns+title checks if the user has access rights for this page
@@ -205,23 +205,33 @@
206206 global $wgUser;
207207 if(!$wgUser->useRCPatrol() && !$wgUser->useNPPatrol())
208208 $this->dieUsage("You need the patrol right to request the patrolled flag", 'permissiondenied');
209 - $this->addTables('recentchanges');
210209 // Use a redundant join condition on both
211210 // timestamp and ID so we can use the timestamp
212211 // index
 212+ $index['recentchanges'] = 'rc_user_text';
213213 if(isset($show['patrolled']) || isset($show['!patrolled']))
214214 {
 215+ // Put the tables in the right order for
 216+ // STRAIGHT_JOIN
 217+ $tables = array('revision', 'recentchanges', 'page');
215218 $this->addOption('STRAIGHT_JOIN');
 219+ $this->addWhere('rc_user_text=rev_user_text');
216220 $this->addWhere('rc_timestamp=rev_timestamp');
217221 $this->addWhere('rc_this_oldid=rev_id');
218222 }
219223 else
 224+ {
 225+ $tables[] = 'recentchanges';
220226 $this->addJoinConds(array('recentchanges' => array(
221227 'LEFT JOIN', array(
 228+ 'rc_user_text=rev_user_text',
222229 'rc_timestamp=rev_timestamp',
223230 'rc_this_oldid=rev_id'))));
 231+ }
224232 }
225233
 234+ $this->addTables($tables);
 235+ $this->addOption('USE INDEX', $index);
226236 $this->addFieldsIf('rev_page', $this->fld_ids);
227237 $this->addFieldsIf('rev_id', $this->fld_ids || $this->fld_flags);
228238 $this->addFieldsIf('page_latest', $this->fld_flags);

Follow-up revisions

RevisionCommit summaryAuthorDate
r47048Fix up r47037, which was itself a fix-up of r46845. Change suggested by Brad ...catrope19:24, 9 February 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r46825API: Re-enable ucprop=patrolled and rcshow=patrolled|!patrolled using the tim...catrope23:19, 4 February 2009

Status & tagging log