Configuration modification of MySQL slow query in Windows
jejas 2021-06-04 10:46:12

In the process of dissecting server performance , Slow query is a good tool .

We can set slow_query_log To turn on slow query log ,long_query_time Property to set the slow query definition threshold , Set up slow_query_log_file To define the storage file of slow query log .

What is the current environment windows10,Mysql8.0.15 edition .

1. Query the current slow query configuration

show global variables like 'slow_query%'

2. Query the current slow query definition threshold

show global variables like 'long_query%'

3. Set the storage path of slow query log

set global slow_query_log_file='F:\\ATemp\\slowly.log'

4. Set slow query threshold

set global long_query_time=2, The unit is in seconds , Can be set by long_query_time by 0 To capture all queries .


test :

 select sleep(3);

Generated logs :

C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe, Version: 8.0.15 (MySQL Community Server - GPL). started with:
TCP Port: 3306, Named Pipe: MySQL
Time Id Command Argument
# Time: 2021-05-19T14:38:24.960151Z
# User@Host: root[root] @ localhost [::1] Id: 14
# Query_time: 3.000456 Lock_time: 0.000000 Rows_sent: 1 Rows_examined: 0
use env;
SET timestamp=1621435101;
select sleep(3)
LIMIT 0, 1000;

The information included includes the user who performed the query , Query statement and start time, etc .

Is learning , If there are mistakes or deficiencies , Please point out the communication .


Please bring the original link to reprint ,thank
Similar articles