Make Title::getFirstRevision() ignore the rev_timestamp index
authorRoan Kattouw <roan.kattouw@gmail.com>
Tue, 28 Mar 2017 15:34:56 +0000 (11:34 -0400)
committerRoan Kattouw <roan.kattouw@gmail.com>
Wed, 29 Mar 2017 15:40:12 +0000 (11:40 -0400)
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
includes/page/WikiPage.php

index e45994c..0c5835c 100644 (file)
@@ -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 );
index 4bc8ad6..1d5973b 100644 (file)
@@ -590,7 +590,8 @@ class WikiPage implements Page, IDBAccessObject {
                                ],
                                __METHOD__,
                                [
-                                       'ORDER BY' => 'rev_timestamp ASC'
+                                       'ORDER BY' => 'rev_timestamp ASC',
+                                       'IGNORE INDEX' => 'rev_timestamp'
                                ]
                        );