From 83d9f48a4589f57ee97e536a21ce0206f4ef7e69 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 21 Jun 2007 15:29:05 +0000 Subject: [PATCH] *Add wfQueriesMustScale(), a quick dirt way to see whether we can get away with inefficient queries or if the job queue is best. Will likely need tweaking. --- includes/GlobalFunctions.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 6ab81e509e..bf589711ca 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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; + } +} + ?> -- 2.20.1