How to quickly enable slow log query in mysql (slow-query)

Source: Internet
Author: User

Mysql (slow-query) Quick Method for enabling slow log query mysql has a function that can log down to run slow SQL statements. By default, www.2cto.com without this log opens my. ini, find [mysql] and add long_query_time = 2log-slow-queries = D:/mysql/logs/slow under it. log # Set to write logs there. It can be empty and the system will
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 null. The system will give a default file
Host_name-slow.log, the generated log is literally in the mysql data DIRECTORY log-queries-not-using-indexes, record the query that does not use the index. The following describes common mysqldumpslow parameters. You can use mysqldumpslow-help to query them in detail. Www.2cto.com-s indicates the sorting method. c, t, l, and r indicate the number of records, time, query time, and returned
The number of records is sorted (from large to small). ac, at, al, and ar indicate the corresponding flashback. -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, query MySQL
The monitoring, analysis, and optimization of query statements are of great help.

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.