Bug #44546 Set Long Query Time on DB-by-DB basis
Submitted: 29 Apr 2009 16:57 Modified: 29 Apr 2009 17:20
Reporter: Aaron Macks Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Options Severity:S4 (Feature request)
Version:5.1 OS:Any
Assigned to: CPU Architecture:Any

[29 Apr 2009 16:57] Aaron Macks
Description:
I would like the ability to set the long_query_time variable to a different value on different databases within the same running instance.  At the moment I have a online CMS/Inventory system that needs to respond instantly, and a different system where queries routinely take 20 second, and that's fine.  I'd like the ability to log >5 sec queries on one and only >30 sec queries on the other
thanks

How to repeat:
the Long_query_time can only be set by start time args or in the [mysqld] block.
[29 Apr 2009 17:20] Valeriy Kravchuk
Thank you for the feature request.
[4 May 2009 8:27] Sergei Golubchik
as a workaround you can use init_connect to set long_query_time per user:

 SET GLOBAL init_connect='SET SESSION long_query_time=IF(USER()=="slow_user", 50, 1)';

Note that supporting long_query_time per database isn't simple as a query can span many databases (select * from db1.t1, db2.t2;)