Home > Database > Mysql Tutorial > What is mysql slow query

What is mysql slow query

little bottle
Release: 2019-05-31 18:00:19
Original
5065 people have browsed it

MySQL slow query is to record SQL statements that run slowly in the log. This function needs to be turned on to be used.

What is mysql slow query

Write in the MySQL configuration file my.cnf:

long_query_time = 10
log-slow-queries = /var/lib/mysql/mysql-slow.log
Copy after login

long_query_time refers to how long the SQL will be logged after execution. Here is 10 seconds.
log-slow-queries is set to write the log there (in the example, the slow query log will be written to the file /var/lib/mysql/mysql-slow.log). When it is empty, the system will write the slow query log. Give the hostname and add slow.log. If the parameter log-long-format is set, all queries that do not use indexes will also be logged.

This is a very useful log. It has a small impact on performance (assuming all queries are fast) and emphasizes those queries that require the most attention (indexes are missing or not being used optimally).

Recommended tutorial: MySQL video tutorial

The above is the detailed content of What is mysql slow query. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template