Reduce use of FORCE INDEX in LogPager
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 19 Sep 2013 19:51:16 +0000 (12:51 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 19 Sep 2013 20:08:59 +0000 (13:08 -0700)
* This currently hurts some change tag queries by orders of mangitude.
  MySQL/Maria query planning is also a fair bit smarter than it used to
  be. Lastly, WMF table statistics are better maintained now.

Change-Id: I4d0ac7a35c9cec6b47771aae718b44bfc03bdfbe

includes/logging/LogPager.php

index 3fb7b89..f8403ca 100644 (file)
@@ -253,16 +253,13 @@ class LogPager extends ReverseChronologicalPager {
                # the choices of available indexes. This mainly
                # avoids site-breaking filesorts.
                } elseif ( $this->title || $this->pattern || $this->performer ) {
-                       $index['logging'] = array( 'page_time', 'user_time' );
-                       if ( count( $this->types ) == 1 ) {
-                               $index['logging'][] = 'log_user_type_time';
-                       }
+                       $index['logging'] = array( 'page_time', 'user_time', 'log_user_type_time' );
                } elseif ( count( $this->types ) == 1 ) {
-                       $index['logging'] = 'type_time';
-               } else {
-                       $index['logging'] = 'times';
+                       $index['logging'] = 'type_time'; // @TODO: sucks for change tags
+               }
+               if ( count( $index ) ) {
+                       $options['USE INDEX'] = $index;
                }
-               $options['USE INDEX'] = $index;
                # Don't show duplicate rows when using log_search
                $joins['log_search'] = array( 'INNER JOIN', 'ls_log_id=log_id' );