EBernhardson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/306803

Change subject: Suggest database to use pl_namespace index for link counting
......................................................................

Suggest database to use pl_namespace index for link counting

Our prod mysql servers are generating a poor query plan for this
query that only uses the index for the namespace lookup and not the
title. I can't particularly explain why (the index mysql chooses and
the index provided here have the same first two fields, which are
the two we are querying), but when using this index mysql chooses
to use the index for the pl_title field as well which runs the
query orders of magnitude faster.

Bug: T143932
Change-Id: I0b648475aee2e3d64eeaad02b3c25f9c300c9602
(cherry picked from commit f75c3f147691173f624769a4cdbac575c5f17f3c)
---
M includes/BuildDocument/RedirectsAndIncomingLinks.php
1 file changed, 3 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch 
refs/changes/03/306803/1

diff --git a/includes/BuildDocument/RedirectsAndIncomingLinks.php 
b/includes/BuildDocument/RedirectsAndIncomingLinks.php
index 8e0c89a..57332dd 100644
--- a/includes/BuildDocument/RedirectsAndIncomingLinks.php
+++ b/includes/BuildDocument/RedirectsAndIncomingLinks.php
@@ -98,7 +98,9 @@
 
                $condition = $dbr->makeList( $conditions, LIST_OR );
 
-               $res = $dbr->selectField( 'pagelinks', 'count(1)', $condition, 
__METHOD__ );
+               $res = $dbr->selectField( 'pagelinks', 'count(1)', $condition, 
__METHOD__, [
+                       'USE INDEX' => 'pl_namespace',
+               ]);
                if ( $res === false ) {
                        return null;
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/306803
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0b648475aee2e3d64eeaad02b3c25f9c300c9602
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: wmf/1.28.0-wmf.16
Gerrit-Owner: EBernhardson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to