From: Roan Kattouw Date: Tue, 28 Mar 2017 15:34:56 +0000 (-0400) Subject: Make Title::getFirstRevision() ignore the rev_timestamp index X-Git-Tag: 1.31.0-rc.0~3656^2~1 X-Git-Url: http://git.cyclocoop.org///%22%40url%40//%22?a=commitdiff_plain;h=dee457713b1b110bff1dc9985eabd487c5d8877c;p=lhc%2Fweb%2Fwiklou.git Make Title::getFirstRevision() ignore the rev_timestamp index We want the page_timestamp index to be used in this case, but sometimes the rev_timestamp is chosen which leads to bad performance. Also update WikiPage::getOldestRevision() which uses the exact same query. I'll implement one in terms of the other in a follow-up commit. Bug: T159319 Change-Id: I7c5c0a9b1af99ce2b5f4bdcc99710d8400ca8bcf --- diff --git a/includes/Title.php b/includes/Title.php index e45994c094..0c5835ca42 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -4028,7 +4028,11 @@ class Title implements LinkTarget { $row = $db->selectRow( 'revision', Revision::selectFields(), [ 'rev_page' => $pageId ], __METHOD__, - [ 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 1 ] + [ + 'ORDER BY' => 'rev_timestamp ASC', + 'LIMIT' => 1, + 'IGNORE INDEX' => 'rev_timestamp' + ] ); if ( $row ) { return new Revision( $row ); diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 4bc8ad6125..1d5973b809 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -590,7 +590,8 @@ class WikiPage implements Page, IDBAccessObject { ], __METHOD__, [ - 'ORDER BY' => 'rev_timestamp ASC' + 'ORDER BY' => 'rev_timestamp ASC', + 'IGNORE INDEX' => 'rev_timestamp' ] );