MySQL slow Query
The slow query (slow log) helps us locate specific SQL statements for SQL statement optimization. For example, the slow query log records the SQL statements whose execution time exceeds the given value, locate the problem.
Enable
MySQL Slow Query Log)
Like most relational databases, log files are an important part of MySQL databases. MySQL has several different log files, such as error log files, binary logs, common logs, and slow query logs. These logs help us locate the
MySQL slow Query
Brief description:
To analyze the query performance of MySQL statements, in addition to using the EXPLAIN command to output the execution plan, MySQL can also record the statements whose query exceeds the specified time, the SQL
Shell script analyzes mysql slow query log (slow log) and mysqlslow
Percona pt-query-digest is used to analyze slow query logs. The analysis and statistics results are clear.
#! /Bin/sh
Slowlog_path =/root/slow_query_log
Everyslow
MySQL slow query log and MySQL Log
MySQL has a log called slow query log, which is mainly used to record time-consuming query operations.
. Through this log, we can analyze which operations affect performance, and we need
Some optimization
Deploy mongous and MySQL slow query Configurations Based on Docker
Deployment of Lepus In the Docker tutorial (MySQL Monitoring)
Introduction
Lepus is an enterprise-level database monitoring system developed by Python + PHP. It can be used in MySQL,
Analysis of a mysql slow query accidentYears ago, the project team received a public account. After the launch, the SQL statements used to query sessions in the cid column are dozens of times slower! I have been thinking about this problem for a
1 Slow query definitionMySQL records all SQL statements that execute a time threshold that exceeds the Long_query_time parameter setting. The slow query log is the log that logs these SQL.
2 Open Slow query logLocate the MySQL configuration file my.
MySQL can record all slow queries and record the SQL statements in the specified file, or you can add updates through the Mysqlbinlog record, or you can restore the database through Mysqlbinlog.
MySQL Slow query record
Edit My.cnf File
Linux is
--Set the log file locationSet global slow_query_log_file =/sql_log/slow_log.log;--Set whether to enable logging without using an indexed SQLSet global log_queries_not_using_indexes = on;--Set the SQL that records execution time beyond the set value
Turn on slow query logAdd two configuration parameters under the [mysqld] line in the configuration file my.cnf or My.iniSlow_query_log = on #开启慢查询long_query_time=1 #设置慢查询时间 1 s Slow_query_log_file="d:/phpstudy/mysql/data/slow_query.log"
OverviewMysqlsla is a very good MySQL slow query log analysis tool, and easy to use. Mysqlsla is a script written in Perl that requires support for PERL-DBI and per-dbd-mysql two modules.Installation Environment
CentOS 7.1
Percona 5.7
2.
slow query (slow log) can help us navigate to specific SQL statements for SQL statement-level optimizations, for example, the slow query log records those execution times that exceed a given SQL statement, thus locating the problem.Turn on Slow
Installing MysqlslaSource Path: https://github.com/daniel-nichter/hackmysql.comSource Storage Path:/USR/LOCAL/SRC1. Get the source codeIf you don't have a git command, install git firstYum Install Gitcd/usr/local/srcgit clone
First, IntroductionTurn on the slow query log, you can let the MySQL record query over a specified time of the statement, through the location analysis of performance bottlenecks, to better optimize the performance of the database system.Second,
Mysql>Show variables like 'long%'; Note: This long_query_time is used to define a "slow query" that is slower than the number of seconds.+-----------------+-----------+|Variable_name|Value|+-----------------+-----------+|Long_query_time| 10.000000 |
Original: http://blog.csdn.net/a11085013/article/details/17370053Show variables like '%quer% '; query whether to open a slow query!!Step One: Modify My.ini (mysql config file)Add the following two words to the My.iniLog-slow-queries = "D:\wamp\mysql_
System performance tuning in particular MySQL database tuning a primary basis is the slow query log. Originally there is a powerful tool on Ubantu or CentOS is Percona Toolkit, then how to use Pt-query-digest on Mac?Download Percona ToolkitAccess
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.