From: Aaron Schulz Date: Thu, 21 Jun 2007 15:29:05 +0000 (+0000) Subject: *Add wfQueriesMustScale(), a quick dirt way to see whether we can get away with ineff... X-Git-Tag: 1.31.0-rc.0~52473 X-Git-Url: https://git.cyclocoop.org/admin/?a=commitdiff_plain;h=83d9f48a4589f57ee97e536a21ce0206f4ef7e69;p=lhc%2Fweb%2Fwiklou.git *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. --- 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; + } +} + ?>