Rewritten the query to allow mysql to use indexes

On a system with heavy logging, without this the login procedure took
too long.
This commit is contained in:
Richard Kojedzinszky 2013-09-12 22:46:23 +02:00
parent 0dd98ccdd1
commit 0f5c90bbe4
1 changed files with 1 additions and 1 deletions

View File

@ -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 )