From: Yuri Astrakhan Date: Tue, 31 Oct 2006 21:00:00 +0000 (+0000) Subject: Database: added STRAIGHT_JOIN option for mysql X-Git-Tag: 1.31.0-rc.0~55333 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/gestion/rappel_supprimer.php?a=commitdiff_plain;h=d1c8dbab7e2c3df33427a709a789bbf6b297ceb9;p=lhc%2Fweb%2Fwiklou.git Database: added STRAIGHT_JOIN option for mysql API: Optimized logevents module query --- 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");