Merge "Restore index forcing in ContribsPager"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 7 Mar 2018 17:21:12 +0000 (17:21 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 7 Mar 2018 17:21:12 +0000 (17:21 +0000)
includes/specials/pagers/ContribsPager.php

index cd04995..520e88d 100644 (file)
@@ -218,8 +218,18 @@ class ContribsPager extends RangeChronologicalPager {
                                $queryInfo['conds'][] = $ipRangeConds;
                        } else {
                                // tables and joins are already handled by Revision::getQueryInfo()
-                               $queryInfo['conds'][] = ActorMigration::newMigration()
-                                       ->getWhere( $this->mDb, 'rev_user', $user )['conds'];
+                               $conds = ActorMigration::newMigration()->getWhere( $this->mDb, 'rev_user', $user );
+                               $queryInfo['conds'][] = $conds['conds'];
+                               // Force the appropriate index to avoid bad query plans (T189026)
+                               if ( count( $conds['orconds'] ) === 1 ) {
+                                       if ( isset( $conds['orconds']['actor'] ) ) {
+                                               // @todo: This will need changing when revision_comment_temp goes away
+                                               $queryInfo['options']['USE INDEX']['temp_rev_user'] = 'actor_timestamp';
+                                       } else {
+                                               $queryInfo['options']['USE INDEX']['revision'] =
+                                                       isset( $conds['orconds']['userid'] ) ? 'user_timestamp' : 'usertext_timestamp';
+                                       }
+                               }
                        }
                }