Quick Start of MySQL slow log query method bitsCN.com
MySQL slow log query is unfamiliar to many new users who are new to MySQL data. The following describes the usage and benefits of MySQL slow Log Query for your reference. Mysql has a function to log down and run slow SQL statements. by default, this log is disabled. ini, find [mysqld] and add long_query_time = 2log-slow-queries = D:/mysql/logs/slow under it. log # set to write logs there. it can be empty. The system will give a default file # log-slow-queries =/var/youpath/slow. in log linux, the host_name-slow.loglog-queries-not-using-indexes long_query_time is the length of time (in seconds) after which the SQL statement will be recorded, which is set to 2 seconds. Log-slow-queries sets the location of the log, which can be empty, the system will give a default file host_name-slow.log, the generated log is literally stored in the mysql data Directory log-queries-not-using-indexes, and the query without indexes is recorded. The following describes common mysqldumpslow parameters. you can use mysqldumpslow-help to query them in detail. -S indicates the sorting method. c, t, l, and r are sorted by the number of records, time, query time, and number of returned Records (from large to small ), ac, at, al, and ar indicate reverse descriptions. -T indicates the top n, that is, the number of previous data records returned. -G, followed by a regular expression matching mode, which is case insensitive. Next is to use mysql's built-in slow query tool mysqldumpslow analysis (mysql bin directory), I here the log file name is host-slow.log. List the 10 SQL statements with the most record times mysqldumpslow-s c-t 10 host-slow.log list the 10 SQL statements that return the record set up to mysqldumpslow-s r-t 10 host-slow.log returns the first 10 times by time SQL statement mysqldumpslow-s t-t 10-g "left join" host-slow.log using mysqldumpslow command can be very clear to get a variety of query statements we need, it is of great help to monitor, analyze, and optimize MySQL Query statements.
IloveyinbitsCN.com
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.