From c3147eb053e0fb4c60f8feddc7de1bc363210d02 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 12 Dec 2012 15:37:21 -0800 Subject: [PATCH] [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 --- includes/job/JobQueueDB.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 -- 2.20.1