Mysql Slow Query log

Source: Internet
Author: User
Tags mysql slow query log

View status show VARIABLES like '%slow_query_log% '

Turn on set global show_query_log=1 (fail after reboot)

Permanent effect Modification MY.CNF join

Slow_query_log=1

Show_query_log_file=/var/lib/mysql/at-slow.log

Modify Time Threshold (default is >10s)

SHOW VARIABLES like ' long_query_time% '

SET GLOBAL long_query_time=3

After setting, you need to open an interface to see the value

Simulation: By performing Selec sleep (4), and then look at the log file as the following effect

Log Analysis Tool Mysqldumpslow

S: Sort by what way

C: Number of visits

L: Lockout time

R: Return record

T: Query time

Al: Average lockout time

AR: Average number of returned records

At: Average query time

T: Returns the number of previous data

G: Behind with a regular match pattern, case insensitive

Common return recordsets up to 10 SQL

Mysqldumpslow-s r-t 10/var/lib/mysql/**-slow.log

10 most visited SQL

-S C-T 10/var/lib/mysql/**-slow.log

Sort by search time first 10 queries with left connection

-S T-t 10-g "left join" **.log

Recommended Use | More piece of use to prevent pop-up screen

-S T-t 10-g "left join" **.log | More

Mysql Slow Query log

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.