Slow query related configuration

-- Check if slow query is enabled

SHOW VARIABLES LIKE '%slow_query_log%' ;

 

-- 1: Enable 0: Disable 

SET GLOBAL slow_query_log = 1

 

-- View slow query log file save path

SHOW VARIABLES LIKE 'slow_query_log_file'

 

-- View the query threshold for slow queries Unit: milliseconds >long_query_time

SHOW VARIABLES LIKE 'long_query_time'

 

-- Set the query time threshold

SET GLOBAL long_query_time = 2

 

-- Re-open a connection after setting, otherwise it will still be the original value

SHOW VARIABLES LIKE 'long_query_time'

 

-- View the value after setting the value of the current setting

SHOW  GLOBAL VARIABLES LIKE 'long_query_time'

 

-- The parameter is the storage method of the specified log

SHOW VARIABLES LIKE 'log_output'

 

-- The default is FILE, and TABLE can be set -- MySQL database supports two log storage methods at the same time, which can be separated by commas when configuring, such as: log_output='FILE, TABLE'

SET GLOBAL log_output='FILE,TABLE';

 

-- Queries that do not use indexes are also recorded in the slow query log. In fact, sql using full index scan will also be recorded in the slow query log.

SHOW VARIABLES LIKE 'log_queries_not_using_indexes';

 

-- Queries that set unused indexes are also logged in the slow query log

SET GLOBAL log_queries_not_using_indexes=1;

 

-- The system variable log_slow_admin_statements indicates whether to record slow management statements such as ANALYZE TABLE and ALTER TABLE in the slow query log

SHOW VARIABLES LIKE 'log_slow_admin_statements';

 

-- 如果你想查询有多少条慢查询记录,可以使用系统变量。

SHOW GLOBAL STATUS LIKE '%Slow_queries%';

 

参考地址:http://mp.weixin.qq.com/s?__biz=MzA5ODM5MDU3MA==&mid=2650862020&idx=1&sn=dd5178f58e27fc0b9deec83d40090b6f&scene=1&srcid=0917UYBkHvB1duZxHcERoG2l#rd

 

 http://www.linuxidc.com/Linux/2012-08/69398.htm

 -- binlog

http://www.cnblogs.com/xionghui/archive/2012/03/11/2389792.html

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326643944&siteId=291194637