From: Bartosz DziewoƄski Date: Tue, 9 Feb 2016 12:46:31 +0000 (+0100) Subject: Special:NewFiles: Make 'hidepatrolled' query less slow X-Git-Tag: 1.31.0-rc.0~7807^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=commitdiff_plain;h=211e5d05a0e1bc1b5bcb8aef6413f43032ba5529;p=lhc%2Fweb%2Fwiklou.git Special:NewFiles: Make 'hidepatrolled' query less slow We're ordering by img_timestamp, so we have to make sure MariaDB queries `image` first. It sometimes decides to query `recentchanges` first and filesort the result set later to get the right ordering. This is probably . Also added missing 'rc_namespace' condition. Bug: T124205 Change-Id: Iad7c96ed452907db3b425a1a53ea098528b4dc23 --- diff --git a/includes/specials/SpecialNewimages.php b/includes/specials/SpecialNewimages.php index ec8c1287fb..e0c0316efa 100644 --- a/includes/specials/SpecialNewimages.php +++ b/includes/specials/SpecialNewimages.php @@ -105,6 +105,7 @@ class NewFilesPager extends ReverseChronologicalPager { function getQueryInfo() { $conds = $jconds = []; $tables = [ 'image' ]; + $options = []; if ( !$this->showBots ) { $groupsWithBotPermission = User::getGroupsWithPermission( 'bot' ); @@ -127,6 +128,7 @@ class NewFilesPager extends ReverseChronologicalPager { $conds['rc_type'] = RC_LOG; $conds['rc_log_type'] = 'upload'; $conds['rc_patrolled'] = 0; + $conds['rc_namespace'] = NS_FILE; $jconds['recentchanges'] = [ 'INNER JOIN', [ @@ -135,6 +137,10 @@ class NewFilesPager extends ReverseChronologicalPager { 'rc_timestamp = img_timestamp' ] ]; + // We're ordering by img_timestamp, so we have to make sure MariaDB queries `image` first. + // It sometimes decides to query `recentchanges` first and filesort the result set later + // to get the right ordering. T124205 / https://mariadb.atlassian.net/browse/MDEV-8880 + $options[] = 'STRAIGHT_JOIN'; } if ( !$this->getConfig()->get( 'MiserMode' ) && $this->like !== null ) { @@ -154,7 +160,8 @@ class NewFilesPager extends ReverseChronologicalPager { 'tables' => $tables, 'fields' => '*', 'join_conds' => $jconds, - 'conds' => $conds + 'conds' => $conds, + 'options' => $options, ]; return $query;