"Log slow queries": Where are they logged?

I have “Log slow queries” selected in Admin->general settings. Where are they supposed to show up?

The only query time logs I see are when I set the log level to “info”, but then I see all query times, not just slow queries…

I must be missing something…

This is the relevant code form DBManager.php:

        protected function dump_slow_queries($query)
                global $sugar_config;

                $do_the_dump = isset($sugar_config['dump_slow_queries'])
                        ? $sugar_config['dump_slow_queries'] : false;
                $slow_query_time_msec = isset($sugar_config['slow_query_time_msec'])
                        ? $sugar_config['slow_query_time_msec'] : 5000;

                if($do_the_dump) {
                        if($slow_query_time_msec < ($this->query_time * 1000)) {
                                // Then log both the query and the query time
                                $this->log->fatal('Slow Query (time:'.$this->query_time."\n".$query);
                                return true;
                return false;

Those configuration values come from config.php, maybe your threshold isn’t being met?

The messages would to be logged as FATAL.

I have the option enabled but nothing prints in the logs. If l search for the string “dump_slow_queries” in the code, I don’t see it being called other than in the file database/MssqlManager.php. Nothing in database/MysqlManager.php. Must be a bug?

I don’t know if I would call it a bug, but yeah, it seems to be a MSSql thing only…

I’ll probably post it to github as a bug because I know way back when this used to work. Anyways, I’ve added in the file include/database/MysqliManager.php on line 143:


And my slow queries are now being logged.

I just checked the old SugarCRM codebase and it’s exactly the same as ours:

So either you saw it a LONG time ago, or it was in a MSSql set up.

Anyway, you are right, this could be useful for MySQL also, so if it works ok, you should do the PR to include it in SuiteCRM. Thanks.

It must’ve been MSSQL because when I first started with CE it was with MSSQL. Makes sense. I will post to github.

Log slow queries for MySQL #3119