Get the App
SLTechnology News&Howtos  ›  Database  › 

What does slow query refer to in MySQL

Shulou Source: shulou.com Published: 2022-05-31 23:45:11 09月11日 Update

This article mainly introduces what the slow query in MySQL refers to. It is very detailed and has a certain reference value. Friends who are interested must finish it!

The method to analyze the query performance of MySQL statements not only uses EXPLAIN output execution plan, but also allows MySQL to record statements that exceed a specified time. We call a SQL statement query that exceeds a specified time as a "slow query".

MySQL slow query is to record slow SQL statements in the log, which needs to be turned on before it can be used.

Write in the configuration file my.cnf of MySQL:

Long_query_time = 10log-slow-queries = / var/lib/mysql/mysql-slow.log

Long_query_time refers to how long the SQL will be logged, in this case, 10 seconds.

The log-slow-queries setting writes the log there (in the example, the slow log will be written to the file / var/lib/mysql/mysql-slow.log). If it is empty, the system will give the slow log a hostname and add slow.log. If the parameter log-long-format is set, all queries that do not use the index will also be logged.

This is a very useful journal. It has little impact on performance (assuming that all queries are fast) and emphasizes the queries that need the most attention (missing indexes or indexes that are not best applied).

The above is all the content of the article "what is slow query in MySQL". Thank you for your reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Queries logs statements indexes content performance files time articles small host value examples interests functions parameters guys buddies that is very soon Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Xiaomi Shulou Technology NVidia vpn