Merged r56967 from wmf-deployment: for performance, don't consider pages with very...
authorTim Starling <tstarling@users.mediawiki.org>
Thu, 3 Dec 2009 05:38:32 +0000 (05:38 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Thu, 3 Dec 2009 05:38:32 +0000 (05:38 +0000)
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

index e8d1bcd..1730159 100644 (file)
@@ -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";
        }
 
        /**