Use IGNORE INDEX(ls_log_id) instead of FORCE INDEX(ls_field_val)
authorRoan Kattouw <roan.kattouw@gmail.com>
Wed, 3 May 2017 15:00:08 +0000 (08:00 -0700)
committerRoan Kattouw <roan.kattouw@gmail.com>
Wed, 3 May 2017 15:00:08 +0000 (08:00 -0700)
ls_field_val was renamed to PRIMARY, but this is only partially
complete in WMF production. There is only one other index on the
log_search table, so ignoring that one is equivalent to forcing
the other one.

Bug: T17441
Change-Id: I63182a9f94eabb4cc47414d86b02c82bde1e58b0

includes/logging/LogPager.php

index ea28ff2..e02b8a6 100644 (file)
@@ -305,14 +305,13 @@ class LogPager extends ReverseChronologicalPager {
                $options = $basic['options'];
                $joins = $basic['join_conds'];
 
-               $index = [];
                # Add log_search table if there are conditions on it.
                # This filters the results to only include log rows that have
                # log_search records with the specified ls_field and ls_value values.
                if ( array_key_exists( 'ls_field', $this->mConds ) ) {
                        $tables[] = 'log_search';
-                       $index['log_search'] = 'ls_field_val';
-                       $index['logging'] = 'PRIMARY';
+                       $options['IGNORE INDEX'] = [ 'log_search' => 'ls_log_id' ];
+                       $options['USE INDEX'] = [ 'logging' => 'PRIMARY' ];
                        if ( !$this->hasEqualsClause( 'ls_field' )
                                || !$this->hasEqualsClause( 'ls_value' )
                        ) {
@@ -322,9 +321,6 @@ class LogPager extends ReverseChronologicalPager {
                                $options[] = 'DISTINCT';
                        }
                }
-               if ( count( $index ) ) {
-                       $options['USE INDEX'] = $index;
-               }
                # Don't show duplicate rows when using log_search
                $joins['log_search'] = [ 'INNER JOIN', 'ls_log_id=log_id' ];