*Add wfQueriesMustScale(), a quick dirt way to see whether we can get away with ineff...
authorAaron Schulz <aaron@users.mediawiki.org>
Thu, 21 Jun 2007 15:29:05 +0000 (15:29 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Thu, 21 Jun 2007 15:29:05 +0000 (15:29 +0000)
includes/GlobalFunctions.php

index 6ab81e5..bf58971 100644 (file)
@@ -2294,4 +2294,25 @@ function wfLocalFile( $title ) {
        return RepoGroup::singleton()->getLocalRepo()->newFile( $title );
 }
 
+function wfQueriesMustScale() {
+       global $wgMiserMode;
+       // If $wgMiserMode is true, it is either large or just cheap, other way the
+       // affect is the same...
+       if( $wgMiserMode )
+               return true;
+       // Try to roughly guess how large this wiki is.
+       // Useful for figuring out if a query that doesn't scale should be avoided
+       // or if job queue should be used
+       $dbr = wfGetDB( DB_SLAVE );
+       $stats = $dbr->selectRow('site_stats', 
+               array('ss_total_pages AS pages','ss_total_edits as edits','ss_users AS users'),
+               array(),
+               __METHOD__);
+       if( $stats->pages > 100000 && $stats->edits > 1000000 && $stats->users > 10000 ) {
+               return true;
+       } else {
+               return false;
+       }
+}
+
 ?>