Database: added STRAIGHT_JOIN option for mysql
authorYuri Astrakhan <yurik@users.mediawiki.org>
Tue, 31 Oct 2006 21:00:00 +0000 (21:00 +0000)
committerYuri Astrakhan <yurik@users.mediawiki.org>
Tue, 31 Oct 2006 21:00:00 +0000 (21:00 +0000)
API: Optimized logevents module query

includes/Database.php
includes/api/ApiQueryBase.php
includes/api/ApiQueryLogEvents.php

index 9225d94..04a3731 100644 (file)
@@ -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';
index 16b265c..8794c48 100644 (file)
@@ -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) {
index 40dd913..93541d3 100644 (file)
@@ -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");