diff options
author | Urban Müller | 2010-05-06 14:31:24 +0000 |
---|---|---|
committer | Urban Müller | 2010-05-06 14:31:24 +0000 |
commit | 2e0427d1bc97fb963a76ddb9daa1d9969f74027f (patch) | |
tree | d6f8115cb69eefc5e34963af5edf396b0faae919 | |
parent | c45905e16593dbee4f6fb1e5ce94fea39b3304a4 (diff) | |
download | itools-2e0427d1bc97fb963a76ddb9daa1d9969f74027f.tar.gz itools-2e0427d1bc97fb963a76ddb9daa1d9969f74027f.tar.bz2 itools-2e0427d1bc97fb963a76ddb9daa1d9969f74027f.zip |
log slow queries
-rw-r--r-- | it_dbi.class | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/it_dbi.class b/it_dbi.class index 9ccfd48..368045b 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -431,7 +431,7 @@ function clear($pp = true) function query($query, $p = array()) { $p += $this->_p; - $start = gettimeofday(); + $start = gettimeofday(true); if ($p['server_update'] && !preg_match('/^(EXPLAIN|SELECT|SHOW) /i', $query)) { @@ -468,12 +468,12 @@ function query($query, $p = array()) } - if ($GLOBALS['debug_sqllog'] || $GLOBALS['debug_sqltrace']) + $msec = round(1000 * (gettimeofday(true) - $start)); + $slow = $msec >= 2000; + if ($GLOBALS['debug_sqllog'] || $GLOBALS['debug_sqltrace'] || $slow) { - $end = gettimeofday(); - $msec = round(($end['sec'] - $start['sec']) * 1000 + ($end['usec'] - $start['usec']) / 1000); - $backtrace = EDC('sqltrace') ? it_debug::backtrace(1) : null; - it::log('sqllog', rtrim("$msec\t$query\t$backtrace")); + $backtrace = (EDC('sqltrace') || $slow) ? it_debug::backtrace(1) : null; + it::log('sqllog', rtrim("$msec\t$query\t$backtrace" . ($slow ? "\tSLOW" : ""))); $this->_sqllog[] = array( 'time' => $msec, |