From d1c8dbab7e2c3df33427a709a789bbf6b297ceb9 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Tue, 31 Oct 2006 21:00:00 +0000 Subject: [PATCH] Database: added STRAIGHT_JOIN option for mysql API: Optimized logevents module query --- includes/Database.php | 1 + includes/api/ApiQueryBase.php | 7 +++++-- includes/api/ApiQueryLogEvents.php | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/includes/Database.php b/includes/Database.php index 9225d94ff9..04a3731915 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -981,6 +981,7 @@ class Database { if ( isset( $noKeyOptions['DISTINCT'] ) && isset( $noKeyOptions['DISTINCTROW'] ) ) $startOpts .= 'DISTINCT'; # Various MySQL extensions + if ( isset( $noKeyOptions['STRAIGHT_JOIN'] ) ) $startOpts .= ' /*! STRAIGHT_JOIN */'; if ( isset( $noKeyOptions['HIGH_PRIORITY'] ) ) $startOpts .= ' HIGH_PRIORITY'; if ( isset( $noKeyOptions['SQL_BIG_RESULT'] ) ) $startOpts .= ' SQL_BIG_RESULT'; if ( isset( $noKeyOptions['SQL_BUFFER_RESULT'] ) ) $startOpts .= ' SQL_BUFFER_RESULT'; diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index 16b265cb22..8794c48ef2 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -103,8 +103,11 @@ abstract class ApiQueryBase extends ApiBase { $this->addOption('ORDER BY', $field . ($isDirNewer ? '' : ' DESC')); } - protected function addOption($name, $value) { - $this->options[$name] = $value; + protected function addOption($name, $value = null) { + if (is_null($value)) + $this->options[] = $name; + else + $this->options[$name] = $value; } protected function select($method) { diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php index 40dd9131f5..93541d3eac 100644 --- a/includes/api/ApiQueryLogEvents.php +++ b/includes/api/ApiQueryLogEvents.php @@ -42,6 +42,8 @@ class ApiQueryLogEvents extends ApiQueryBase { $db = & $this->getDB(); extract($db->tableNames('logging', 'page', 'user'), EXTR_PREFIX_ALL, 'tbl'); + + $this->addOption('STRAIGHT_JOIN'); $this->addTables("$tbl_logging LEFT OUTER JOIN $tbl_page ON " . "log_namespace=page_namespace AND log_title=page_title " . "INNER JOIN $tbl_user ON user_id=log_user"); -- 2.20.1