Use of profile in MySQL

Source: Internet
Author: User

1.profile available in mysql5.0.37 and above


2. See if profile is available
SELECT @ @profiling;
to see if profile is enabled, and if the PROFILNG value is 0, you can
SET profiling = 1;
enabled
mysql>select Count (*) from roi_summary;

then show Profiles view as follows:


+----------------+------------+----------------------------------+
| query_id | Duration | Query |
+----------------+------------+----------------------------------+
| 1 | 0.00021500 | SELECT @ @profiling |
| 2 | 0.05522700 | Select COUNT (*) from Roi_summary |
+----------------+------------+----------------------------------+

where the statement with ID 5 is the query statement that was just executed
mysql> Show profile for query 2;
analyze its performance
+--------------------------------+----------+
| Status | Duration |
+--------------------------------+----------+
| (initialization) | 0.000004 |
| checking query cache for Query | 0.000044 |
| Opening Tables | 0.000012 |
| System Lock | 0.000017 |
| Table Lock | 0.00003 |
| init | 0.000013 |
| optimizing | 0.000008 |
| statistics | 0.000013 |
| preparing | 0.000011 |
| executing | 0.000006 |
| Sending Data | 0.747313 |
| end | 0.000014 |
| query End | 0.000006 |
| Storing result in query cache | 0.000006 |
| freeing items | 0.000012 |
| closing Tables | 0.000009 |
| logging slow query | 0.000183 |
+--------------------------------+----------+
$ rows in Set (0.00 sec)

#查看cpu IO memory swaps
mysql> Show profile Cpu,block io,memory,swaps for query 2;


Note:
1.profile is a user-level variable and must be re-enabled each time
2. Need to be used in terminal, invalid under phpMyAdmin

Use of profile in MySQL

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.