From dee457713b1b110bff1dc9985eabd487c5d8877c Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Tue, 28 Mar 2017 11:34:56 -0400 Subject: [PATCH] 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 --- includes/Title.php | 6 +++++- includes/page/WikiPage.php | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) 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' ] ); -- 2.20.1