From: Aaron Schulz Date: Wed, 12 Dec 2012 23:37:21 +0000 (-0800) Subject: [JobQueue] Kill ORDER BY in job claim function. X-Git-Tag: 1.31.0-rc.0~21315 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=c3147eb053e0fb4c60f8feddc7de1bc363210d02;p=lhc%2Fweb%2Fwiklou.git [JobQueue] Kill ORDER BY in job claim function. * Although indexed, this slows down for some reason. This started to waste master CPU time for wmf wikis with hundreds of thousands of jobs. Given how the DB scans the index, the function still works correctly without the ORDER BY. Change-Id: I6ba6cc65d0023de3b9d9df0cfcd6a403289c9848 --- diff --git a/includes/job/JobQueueDB.php b/includes/job/JobQueueDB.php index c928682761..719761b6ce 100644 --- a/includes/job/JobQueueDB.php +++ b/includes/job/JobQueueDB.php @@ -200,7 +200,6 @@ class JobQueueDB extends JobQueue { */ protected function claimRandom( $uuid, $rand, $gte ) { $dbw = $this->getMasterDB(); - $dir = $gte ? 'ASC' : 'DESC'; $ineq = $gte ? '>=' : '<='; $row = false; // the row acquired @@ -214,8 +213,8 @@ class JobQueueDB extends JobQueue { 'job_cmd' => $this->type, 'job_token' => '', "job_random {$ineq} {$dbw->addQuotes( $rand )}" ), - __METHOD__, - array( 'ORDER BY' => "job_random {$dir}" ) + __METHOD__ + // Bug 42614: "ORDER BY job_random" causes slowness on mysql for some reason ); if ( $row ) { // claim the job $dbw->update( 'job', // update by PK