From: Brad Jorsch Date: Wed, 14 Sep 2016 14:13:10 +0000 (-0400) Subject: API: Force straight join for prop=linkshere|transcludedin|fileusage X-Git-Tag: 1.31.0-rc.0~5528^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22suivi_revisions%22%29%20.%20%22?a=commitdiff_plain;h=81912c3ef943d8a702ea60aa67f4abe9e22cdabe;p=lhc%2Fweb%2Fwiklou.git API: Force straight join for prop=linkshere|transcludedin|fileusage MySQL (or at least 5.5.5-10.0.23-MariaDB) chooses a really bad query plan if it thinks there will be more matching rows in the linktable than are in page. Use STRAIGHT_JOIN here to force it to use the intended, fast plan. See T145079 for details. Bug: T145079 Change-Id: I1a363450b818a049938145d0feb207c9894d2a49 --- diff --git a/includes/api/ApiQueryBacklinksprop.php b/includes/api/ApiQueryBacklinksprop.php index 236fb9e06c..8e89c32e50 100644 --- a/includes/api/ApiQueryBacklinksprop.php +++ b/includes/api/ApiQueryBacklinksprop.php @@ -264,6 +264,12 @@ class ApiQueryBacklinksprop extends ApiQueryGeneratorBase { } } + // MySQL (or at least 5.5.5-10.0.23-MariaDB) chooses a really bad query + // plan if it thinks there will be more matching rows in the linktable + // than are in page. Use STRAIGHT_JOIN here to force it to use the + // intended, fast plan. See T145079 for details. + $this->addOption( 'STRAIGHT_JOIN' ); + $this->addOption( 'LIMIT', $params['limit'] + 1 ); $res = $this->select( __METHOD__ );