MySQL Slow query

Source: Internet
Author: User

sometimes we're less efficient in locating systems. Query syntax, you need to open the slow query log, which is slowquery Log . The command to open the slow query log is as follows:

View

Mysql> showvariables like '%slow% ';

+---------------------+-------------------------------------------+

| variable_name | Value |

+---------------------+-------------------------------------------+

|log_slow_queries | On |

|slow_launch_time |

|slow_query_log | On |

| slow_query_log_file| /app/mysql-5.5.32/data/localhost-slow.log |

+---------------------+-------------------------------------------+

4 rows in Set (0.00SEC)

Mysql> show globalstatus like '%slow% ';

+---------------------+-------+

| variable_name | Value |

+---------------------+-------+

| slow_launch_threads| 0 |

| slow_queries |

+---------------------+-------+

2 rows in Set (0.00SEC)

turning on the slow query log can have a little impact on system performance if your MySQL is a master-slave structure, you can consider opening one of the slow query logs from the server, so that you can monitor the slow query, the impact on the system performance will be very small. In addition, you can use the MySQL command mysqldumpslow to query.

For example, the following command can detect the most frequently accessed - a SQL statement:

[[Email protected] ~] #mysqldumpslow-S c-t 20/app/mysql-5.5.32/data/localhost-slow.log

Attention:

-S ORDER what to sort by (Al, at, AR, C, L, R, T), ' at ' IsDefault

Al:average Lock Time

Ar:average rows Sent

At:average Query Time

C:count

L:lock time

R:rows sent

T:query time

-T NUM just show the top n queries


This article is from a "a little" blog, make sure to keep this source http://pengai.blog.51cto.com/6326789/1890364

MySQL Slow query

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.