What is Slow Query Logging in MairaDB or MySQL and How to Enable Slow Query Log in MySQL or MairaDB

Slow Query Log

Slow query log stores the information for querys that took long time to run.

Enable Slow Query Logging :

For Stand Alone : 

Go to /etc/my.cnf and add below entries


slow_query_log = 1
long_query_time = 1
slow_query_log_file = /var/log/mysql/slow-query.log
log_queries_not_using_indexes=1

For Galera Cluster : 

Go to /etc/my.cnf.d/server.cnf file and add below 


slow_query_log = 1
long_query_time = 1
slow_query_log_file = /var/log/mysql/slow-query.log
log_queries_not_using_indexes=1

Check Current values : 

Login to MySQL or MariaDB and run below queries to check the current settings of slow query logging

 SHOW VARIABLES LIKE 'slow_query_log';

 SHOW VARIABLES LIKE 'long_query_time';

 SHOW VARIABLES LIKE 'slow_query_log_file';


Enable General Log for Table :

To write logs into tables, the log_output server system variable is used. Allowed values are FILE, TABLE and NONE. It is possible to specify multiple values, separated with commas, to write the logs into both tables and files. NONE disables logging and has precedence over the other values.
SET GLOBAL log_output = 'FILE,TABLE';
 If General log is active for table, you can query the table to see the information.


 SELECT * FROM mysql.slow_log;


Video Demo : How to capture long running queries in MySQL or MariaDB



3 comments:

  1. HI, Can you show in window please

    ReplyDelete
  2. The best long range paintball guns are usually used by a sniper. Finding a good one will determine the performance of your game.If you want to be a good sniper on your team, then you need to have a Best Long Range Paintball Gun that is the best on the market. We have done extensive research and have come up with several top-notch options to ensure you make the right decision.

    ReplyDelete