Fix slow query counting by unindexed field ar_page_id
authorTim Starling <tstarling@wikimedia.org>
Wed, 24 Oct 2018 00:21:28 +0000 (17:21 -0700)
committerTim Starling <tstarling@wikimedia.org>
Wed, 24 Oct 2018 00:48:21 +0000 (17:48 -0700)
Bug: T207530
Change-Id: I81a70ca03fd219d2e96b17714645d9cc4f99b3b9

includes/page/WikiPage.php

index 081af19..18797d9 100644 (file)
@@ -2727,8 +2727,13 @@ class WikiPage implements Page, IDBAccessObject {
                        // in the job queue to avoid simultaneous deletion operations would add overhead.
                        // Number of archived revisions cannot be known beforehand, because edits can be made
                        // while deletion operations are being processed, changing the number of archivals.
-                       $archivedRevisionCount = $dbw->selectRowCount(
-                               'archive', '1', [ 'ar_page_id' => $id ], __METHOD__
+                       $archivedRevisionCount = $dbw->selectField(
+                               'archive', 'COUNT(*)',
+                               [
+                                       'ar_namespace' => $this->getTitle()->getNamespace(),
+                                       'ar_title' => $this->getTitle()->getDBkey(),
+                                       'ar_page_id' => $id
+                               ], __METHOD__
                        );
 
                        // Clone the title and wikiPage, so we have the information we need when