Merge "use slave for row estimate in updateCollation.php"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 11 May 2016 17:06:05 +0000 (17:06 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 11 May 2016 17:06:05 +0000 (17:06 +0000)
1  2 
maintenance/updateCollation.php

@@@ -70,6 -70,7 +70,7 @@@ TEX
                global $wgCategoryCollation;
  
                $dbw = $this->getDB( DB_MASTER );
+               $dbr = $this->getDB( DB_SLAVE );
                $force = $this->getOption( 'force' );
                $dryRun = $this->getOption( 'dry-run' );
                $verboseStats = $this->getOption( 'verbose-stats' );
@@@ -97,7 -98,6 +98,7 @@@
                $options = [
                        'LIMIT' => self::BATCH_SIZE,
                        'ORDER BY' => $orderBy,
 +                      'STRAIGHT_JOIN' // per T58041
                ];
  
                if ( $force || $dryRun ) {
                                ];
                        }
  
-                       $count = $dbw->estimateRowCount(
+                       $count = $dbr->estimateRowCount(
                                'categorylinks',
                                '*',
                                $collationConds,
                        );
                        // Improve estimate if feasible
                        if ( $count < 1000000 ) {
-                               $count = $dbw->selectField(
+                               $count = $dbr->selectField(
                                        'categorylinks',
                                        'COUNT(*)',
                                        $collationConds,
                                return;
                        }
                        $this->output( "Fixing collation for $count rows.\n" );
+                       wfWaitForSlaves();
                }
                $count = 0;
                $batchCount = 0;