Bug #69420 log_slow_statement could bail out earlier if slow logging is disabled
Submitted: 7 Jun 2013 7:18 Modified: 16 Oct 2013 15:02
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Logging Severity:S5 (Performance)
Version:5.6.12 OS:Any
Assigned to: CPU Architecture:Any

[7 Jun 2013 7:18] Shane Bester
Description:
All code in function log_slow_applicable is fully run, even if opt_slow_log is 0.

This wastes cpu cycles for each query.  It is not a lot, but I am seeing it show up in profiling when running 400K queries per second in single-threaded testcase.

How to repeat:
o) start server with slow query log disabled.
o) set a breakpoint on function log_slow_applicable
o) run a query, such as "do 1".

Suggested fix:
Please bail out sooner if the server's slow log is disabled.
[16 Oct 2013 15:02] Paul Dubois
Posted by developer:
 
Noted in 5.7.3 changelog.

For queries potentially to be written to the slow query log, the
check whether the log is enabled now occurs earlier, reducing
overhead. 

Also, when log_throttle_queries_not_using_indexes is specified at
server startup, a value is now required. Previously, it was
incorrectly treated as optional.