+ // MySQL's optimizer chokes if we have too many values in "$bl_title IN
+ // (...)" and chooses the wrong index, so specify the correct index to
+ // use for the query. See T139056 for details.
+ if ( !empty( $settings['indexes'] ) ) {
+ list( $idxNoFromNS, $idxWithFromNS ) = $settings['indexes'];
+ if ( $params['namespace'] !== null && !empty( $settings['from_namespace'] ) ) {
+ $this->addOption( 'USE INDEX', [ $settings['linktable'] => $idxWithFromNS ] );
+ } else {
+ $this->addOption( 'USE INDEX', [ $settings['linktable'] => $idxNoFromNS ] );
+ }
+ }
+
+ // MySQL (or at least 5.5.5-10.0.23-MariaDB) chooses a really bad query
+ // plan if it thinks there will be more matching rows in the linktable
+ // than are in page. Use STRAIGHT_JOIN here to force it to use the
+ // intended, fast plan. See T145079 for details.
+ $this->addOption( 'STRAIGHT_JOIN' );
+