Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to locate slow SQL by MySQL

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to locate slow SQL in MySQL". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to locate slow SQL in MySQL.

The direct performance loss caused by slow logs is the most expensive I SQL O resource in the database system. The advantage of turning on slow query records is that SQL statements can be optimized by analyzing slow log.

The steps to enable the slow log feature are as follows:

1) add the following parameters to the my.cnf configuration file:

Slow_query_log=1

Slow_query_log_file=/mysql/data/mysql.slow

Long_query_time=2 (SQL of more than 2 seconds will be recorded)

2) when the number of database connections is high, the slow logs of this period are intercepted through the time point at that time, such as:

Sed-n'/ # Time:110720 16 purge 17purl 40lemag.myqlUniqql.slow > slow.log

Then use the mysqldumpslow command to take out the first 10 slow SQL which takes the longest time for analysis.

Mysqldumpslow-s t-t 10 slow.log

Thank you for your reading, the above is the content of "how to locate slow SQL in MySQL". After the study of this article, I believe you have a deeper understanding of how to locate slow SQL in MySQL, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report