From 73560aeb2cfc15fe0bc77eb8a9c279faf663e19a Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Thu, 27 Aug 2009 14:58:19 +0000 Subject: [PATCH] API: Do a STRAIGHT_JOIN in ApiQueryBacklinks's first query to counter a MySQL 4 bug where the optmizer chooses to do a table scan on page instead. --- includes/api/ApiQueryBacklinks.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php index 4f23d6e501..38b705ac01 100644 --- a/includes/api/ApiQueryBacklinks.php +++ b/includes/api/ApiQueryBacklinks.php @@ -103,7 +103,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { * LIMIT 11 ORDER BY pl_from */ $db = $this->getDB(); - $this->addTables(array('page', $this->bl_table)); + $this->addTables(array($this->bl_table, 'page')); $this->addWhere("{$this->bl_from}=page_id"); if(is_null($resultPageSet)) $this->addFields(array('page_id', 'page_title', 'page_namespace')); @@ -122,6 +122,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $this->addWhereFld('page_is_redirect', 0); $this->addOption('LIMIT', $this->params['limit'] + 1); $this->addOption('ORDER BY', $this->bl_from); + $this->addOption('STRAIGHT_JOIN'); } private function prepareSecondQuery($resultPageSet = null) { -- 2.20.1