From: Aaron Schulz Date: Mon, 7 Oct 2013 16:38:25 +0000 (-0700) Subject: Removed RC query UNION X-Git-Tag: 1.31.0-rc.0~18580 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=8345279e255ca81f88f9c3ea8bc6dde4d4b64f4d;p=lhc%2Fweb%2Fwiklou.git Removed RC query UNION * MySQL is smart enough that this is no longer needed Change-Id: If173cdc53599cd02068ce2480ab667c5f9e69b76 --- diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index a408beb2ce..60cdb0e282 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -424,59 +424,16 @@ class SpecialRecentChanges extends IncludableSpecialPage { return false; } - // Don't use the new_namespace_time timestamp index if: - // (a) "All namespaces" selected - // (b) We want pages in more than one namespace (inverted/associated) - // (c) There is a tag to filter on (use tag index instead) - // (d) UNION + sort/limit is not an option for the DBMS - if ( $namespace === '' - || ( $invert || $associated ) - || $opts['tagfilter'] != '' - || !$dbr->unionSupportsOrderAndLimit() - ) { - $res = $dbr->select( $tables, $fields, $conds, __METHOD__, - array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit ) + - $query_options, - $join_conds ); - } else { - // We have a new_namespace_time index! UNION over new=(0,1) and sort result set! - - // New pages - $sqlNew = $dbr->selectSQLText( - $tables, - $fields, - array( 'rc_new' => 1 ) + $conds, - __METHOD__, - array( - 'ORDER BY' => 'rc_timestamp DESC', - 'LIMIT' => $limit, - 'USE INDEX' => array( 'recentchanges' => 'new_name_timestamp' ) - ), - $join_conds - ); - - // Old pages - $sqlOld = $dbr->selectSQLText( - $tables, - $fields, - array( 'rc_new' => 0 ) + $conds, - __METHOD__, - array( - 'ORDER BY' => 'rc_timestamp DESC', - 'LIMIT' => $limit, - 'USE INDEX' => array( 'recentchanges' => 'new_name_timestamp' ) - ), - $join_conds - ); - - # Join the two fast queries, and sort the result set - $sql = $dbr->unionQueries( array( $sqlNew, $sqlOld ), false ) . - ' ORDER BY rc_timestamp DESC'; - $sql = $dbr->limitResult( $sql, $limit, false ); - $res = $dbr->query( $sql, __METHOD__ ); - } - - return $res; + // rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough + // knowledge to use an index merge if it wants (it may use some other index though). + return $dbr->select( + $tables, + $fields, + $conds + array( 'rc_new' => array( 0, 1 ) ), + __METHOD__, + array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit ) + $query_options, + $join_conds + ); } /**