Mysql enables slow query logs and queries-windows, mysql-windows

Source: Internet
Author: User

Mysql enables slow query logs and queries-windows, mysql-windows

MySQL slow query Configuration

1. What is the use of slow queries?

It records all SQL statements that have been executed longer than long_query_time, and helps you find slow SQL statements to optimize these SQL statements.

2. How to enable slow query?

First, check whether the slow query status of the MYSQL server is enabled. Execute the following command:

Show variables like '% quer % ';

 

We can see that the current log_slow_queries status is OFF, indicating that the slow query is not enabled currently.

It is very easy to enable slow query. The operations are as follows:

Add the following information to [mysqld:

[Mysqld]

Log-slow-queries = "C:/Program Files/MySQL Server 5.5/log/mysql-slow.log"

Long_query_time = 4

Log-queries-not-using-indexes


Log-slow-queries: indicates the log storage directory of MYSQL slow query. This directory must have the write permission;

Windows need to write absolute path, such as: log-slow-queries = "C:/Program Files/MySQL Server 5.5/log/mysql-slow.log"

Long_query_time: Maximum execution time. (MSYQL records all SQL statements that have been executed for more than two times. The test time is used here. The time should not be too small. It is best to set the time to within 5-10 seconds, depending on your own standards );

Log-queries-not-using-indexes: queries that are not indexed will also be recorded in the log.

Restart a MYSQL service after configuration.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.