From 0f5c90bbe46d4e3c0113931426ac50687d45aa5c Mon Sep 17 00:00:00 2001 From: Richard Kojedzinszky Date: Thu, 12 Sep 2013 22:46:23 +0200 Subject: [PATCH] Rewritten the query to allow mysql to use indexes On a system with heavy logging, without this the login procedure took too long. --- web/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/includes/functions.php b/web/includes/functions.php index e446e5703..74ce6da68 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -2167,7 +2167,7 @@ function logState() Logger::WARNING => array( ZM_LOG_ALERT_WAR_COUNT, ZM_LOG_ALARM_WAR_COUNT ), ); - $sql = "select Level, count(Level) as LevelCount from Logs where Level < ".Logger::INFO." and from_unixtime(TimeKey) + interval ".ZM_LOG_CHECK_PERIOD." second > now() group by Level order by Level asc"; + $sql = "select Level, count(Level) as LevelCount from Logs where Level < ".Logger::INFO." and TimeKey > unix_timestamp(now() - interval ".ZM_LOG_CHECK_PERIOD." second) group by Level order by Level asc"; $counts = dbFetchAll( $sql ); foreach ( $counts as $count )