How Do I Enable Slow Query Logging?

Ryan Lecha -

On ClustrixDB there is no individual slow query log. Rather slow queries are logged into the query log based off of the variables session_log_slow_queries and session_log_slow_threshold_ms.

  • session_log_slow_queries: Enables logging of slow queries. Default true.
  • session_log_slow_threshold_ms: slow query threshold in miliseconds. Default 20000.

These queries will enable slow query logging for queries taking over 4 seconds to execute.

SET GLOBAL session_log_slow_threshold_ms = 4000; 

The node that is processing the query will log slow queries into it's own individual query.log. Thus, you must get all the query.logs from all nodes in order to get everything.

This command will get the query logs for each node.

clx cmd 'grep SLOW /var/log/query.log' > /clustrix/slow_query.log 

And this one will sort all the logs by time.

clx cmd 'grep SLOW /var/log/query.log' | sort > /clustrix/slow_query_sorted.log 

You can also set slow query logging for the current session (useful in debugging) with:

SET session_log_slow_threshold_ms = 4000; 

Check out Query Logging for more information

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk