From fe74d822da59c2efea5f22da884349dc9aca3d62 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Fri, 6 Jul 2007 03:55:36 +0000 Subject: [PATCH] Document and clean up wfQueriesMustScale(); less verbose comments inside the function, more function documentation, please -- and don't use an if statement when it's not needed --- includes/GlobalFunctions.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 6f671c3897..b86bd8475b 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2258,24 +2258,25 @@ function wfLocalFile( $title ) { return RepoGroup::singleton()->getLocalRepo()->newFile( $title ); } +/** + * Should low-performance queries be disabled? + * + * @return bool + */ function wfQueriesMustScale() { global $wgMiserMode; - // If $wgMiserMode is true, all queries must be efficient + // Unconditional performance requirement 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 + // Make a rough estimate $dbr = wfGetDB( DB_SLAVE ); - $stats = $dbr->selectRow('site_stats', - array('ss_total_pages AS pages','ss_total_edits as edits','ss_users AS users'), + $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; - } + __METHOD__ + ); + return $stats->pages > 100000 && $stats->edits > 1000000 && $stats->users > 10000; } /** -- 2.20.1