From: Roan Kattouw Date: Mon, 11 Apr 2016 18:08:10 +0000 (-0700) Subject: Force primary index for RevDelRevisionList query X-Git-Tag: 1.31.0-rc.0~5667^2 X-Git-Url: http://git.cyclocoop.org///%22%40url%40//%22?a=commitdiff_plain;h=59f09caabc4c7e58b18d0a88dbb5a7d22d0ef7bd;p=lhc%2Fweb%2Fwiklou.git Force primary index for RevDelRevisionList query To work around an optimizer bug in MySQL where the index on (rev_page, rev_id) is picked which mysteriously leads to very slow execution times and timeouts. In theory, the index being forced here is (rev_id), which is fine for this query. In WMF production, it can also be (rev_id, rev_user) (still fine), or (rev_page, rev_id) (the index we're trying to avoid). Mysteriously, the optimizer bug doesn't happen if (rev_page, rev_id) is the primary key, so this still behaves OK. Bug: T104313 Change-Id: I15c68ba29309dca8dea274f19389d139a82784aa --- diff --git a/includes/revisiondelete/RevDelRevisionList.php b/includes/revisiondelete/RevDelRevisionList.php index 1d08dbe55a..f0b1907d83 100644 --- a/includes/revisiondelete/RevDelRevisionList.php +++ b/includes/revisiondelete/RevDelRevisionList.php @@ -66,7 +66,10 @@ class RevDelRevisionList extends RevDelList { 'rev_page' => $this->title->getArticleID(), 'rev_id' => $ids, ], - 'options' => [ 'ORDER BY' => 'rev_id DESC' ], + 'options' => [ + 'ORDER BY' => 'rev_id DESC', + 'USE INDEX' => [ 'revision' => 'PRIMARY' ] // workaround for MySQL bug (T104313) + ], 'join_conds' => [ 'page' => Revision::pageJoinCond(), 'user' => Revision::userJoinCond(),