From 37ae1ca3f97ea2eab528a04084658ee729de7a45 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Thu, 3 Dec 2009 05:38:32 +0000 Subject: [PATCH] Merged r56967 from wmf-deployment: for performance, don't consider pages with very few links for Special:Mostlinked. Implemented a page count threshold as Domas suggested in his commit message. A fractional power seems to make sense for scaling from page count to links-per-page, since it has the right kind of limits, so I used a square root bounded between 1 and 100. --- includes/specials/SpecialMostlinked.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/includes/specials/SpecialMostlinked.php b/includes/specials/SpecialMostlinked.php index e8d1bcddd8..173015997b 100644 --- a/includes/specials/SpecialMostlinked.php +++ b/includes/specials/SpecialMostlinked.php @@ -23,7 +23,24 @@ class MostlinkedPage extends QueryPage { function isSyndicated() { return false; } function getSQL() { + global $wgMiserMode; + $dbr = wfGetDB( DB_SLAVE ); + + # In miser mode, reduce the query cost by adding a threshold for large wikis + if ( $wgMiserMode ) { + $numPages = SiteStats::pages(); + if ( $numPages > 10000 ) { + $cutoff = 100; + } elseif ( $numPages > 100 ) { + $cutoff = intval( sqrt( $numPages ) ); + } else { + $cutoff = 1; + } + } else { + $cutoff = 1; + } + list( $pagelinks, $page ) = $dbr->tableNamesN( 'pagelinks', 'page' ); return "SELECT 'Mostlinked' AS type, @@ -33,7 +50,7 @@ class MostlinkedPage extends QueryPage { FROM $pagelinks LEFT JOIN $page ON pl_namespace=page_namespace AND pl_title=page_title GROUP BY pl_namespace, pl_title - HAVING COUNT(*) > 1"; + HAVING COUNT(*) > $cutoff"; } /** -- 2.20.1