MySQL Performance Debug Tool profile

Source: Internet
Author: User
Tags switches cpu usage

I've been looking for MySQL. There are no similar tools for Oracle 10046 to see where SQL execution time is spent. Finally find a profile on the Internet, use some, feel good.

Mysql> select version ();
+-----------+
| Version () |
+-----------+
| 5.6.16 |
+-----------+
1 row in Set (0.00 sec)


mysql> SELECT @ @profiling;
+-------------+
| @ @profiling |
+-------------+
| 0 |
+-------------+
1 row in Set, 1 Warning (0.00 sec)


mysql> SET profiling = 1;
Query OK, 0 rows affected, 1 Warning (0.00 sec)


Mysql> Select COUNT (1) from test1 T1,test2 T2;
+----------+
| COUNT (1) |
+----------+
| 7096832 |
+----------+
1 row in Set (0.38 sec)


Mysql> Show profile Cpu,block io for query 1;--for Query 1 is looking at the SQL statement executed by 1th
+--------------------------------+----------+----------+------------+--------------+---------------+
| Status | Duration | Cpu_user | Cpu_system | block_ops_in | Block_ops_out |
+--------------------------------+----------+----------+------------+--------------+---------------+
| Starting | 0.000006 |   0.000000 |         0.000000 |          NULL | NULL |
| Waiting for query Cache lock | 0.000002 |   0.000000 |         0.000000 |          NULL | NULL |
| init | 0.000002 |   0.000000 |         0.000000 |          NULL | NULL |
| Checking query cache for Query | 0.000023 |   0.000000 |         0.000000 |          NULL | NULL |
| Checking Permissions | 0.000003 |   0.000000 |         0.000000 |          NULL | NULL |
| Checking Permissions | 0.000002 |   0.000000 |         0.000000 |          NULL | NULL |
| Opening Tables | 0.000026 |   0.000000 |         0.000000 |          NULL | NULL |
| init | 0.000008 |   0.000000 |         0.000000 |          NULL | NULL |
| System Lock | 0.000007 |   0.000000 |         0.000000 |          NULL | NULL |
| Waiting for query Cache lock | 0.000002 |   0.000000 |         0.000000 |          NULL | NULL |
| System Lock | 0.000022 |   0.000000 |         0.000000 |          NULL | NULL |
| Optimizing | 0.000004 |   0.000000 |         0.000000 |          NULL | NULL |
| Statistics | 0.000012 |   0.000000 |         0.000000 |          NULL | NULL |
| Preparing | 0.000022 |   0.000000 |         0.000000 |          NULL | NULL |
| Executing | 0.000002 |   0.000000 |         0.000000 |          NULL | NULL |
| Sending Data | 0.388263 |   0.375000 |         0.000000 |          NULL | NULL |
| End | 0.000017 |   0.000000 |         0.000000 |          NULL | NULL |
| Query End | 0.000008 |   0.000000 |         0.000000 |          NULL | NULL |
| Closing Tables | 0.000014 |   0.000000 |         0.000000 |          NULL | NULL |
| Freeing items | 0.000006 |   0.000000 |         0.000000 |          NULL | NULL |
| Waiting for query Cache lock | 0.000002 |   0.000000 |         0.000000 |          NULL | NULL |
| Freeing items | 0.000045 |   0.000000 |         0.000000 |          NULL | NULL |
| Waiting for query Cache lock | 0.000002 |   0.000000 |         0.000000 |          NULL | NULL |
| Freeing items | 0.000002 |   0.000000 |         0.000000 |          NULL | NULL |
| Storing result in query cache | 0.000004 |   0.000000 |         0.000000 |          NULL | NULL |
| Cleaning Up | 0.000015 |   0.000000 |         0.000000 |          NULL | NULL |
+--------------------------------+----------+----------+------------+--------------+---------------+
+ Rows in Set, 1 Warning (0.00 sec)


Mysql> Select COUNT (1) from Test1 t1,test2 T2, test2 T3;
+------------+
| COUNT (1) |
+------------+
| 1185170944 |
+------------+
1 row in Set (1 min 26.67 sec)


Mysql> Show profile Cpu,block io for query 2;--for Query 2 is looking at the SQL statement executed by 2nd
+--------------------------------+-----------+-----------+------------+--------------+---------------+
| Status | Duration | Cpu_user | Cpu_system | block_ops_in | Block_ops_out |
+--------------------------------+-----------+-----------+------------+--------------+---------------+
|  Starting |  0.000005 |   0.000000 |         0.000000 |          NULL | NULL |
|  Waiting for query Cache lock |  0.000002 |   0.000000 |         0.000000 |          NULL | NULL |
|  init |  0.000002 |   0.000000 |         0.000000 |          NULL | NULL |
|  Checking query cache for Query |  0.000029 |   0.000000 |         0.000000 |          NULL | NULL |
|  Checking Permissions |  0.000002 |   0.000000 |         0.000000 |          NULL | NULL |
|  Checking Permissions |  0.000002 |   0.000000 |         0.000000 |          NULL | NULL |
|  Checking Permissions |  0.000002 |   0.000000 |         0.000000 |          NULL | NULL |
|  Opening Tables |  0.000071 |   0.000000 |         0.000000 |          NULL | NULL |
|  init |  0.000008 |   0.000000 |         0.000000 |          NULL | NULL |
|  System Lock |  0.000005 |   0.000000 |         0.000000 |          NULL | NULL |
|  Waiting for query Cache lock |  0.000002 |   0.000000 |         0.000000 |          NULL | NULL |
|  System Lock |  0.000021 |   0.000000 |         0.000000 |          NULL | NULL |
|  Optimizing |  0.000004 |   0.000000 |         0.000000 |          NULL | NULL |
|  Statistics |  0.000011 |   0.000000 |         0.000000 |          NULL | NULL |
|  Preparing |  0.000019 |   0.000000 |         0.000000 |          NULL | NULL |
|  Executing |  0.000002 |   0.000000 |         0.000000 |          NULL | NULL |
| Sending Data | 86.679145 |   86.640625 |         0.000000 |          NULL | NULL |
|  End |  0.000024 |   0.000000 |         0.000000 |          NULL | NULL |
|  Query End |  0.000008 |   0.000000 |         0.000000 |          NULL | NULL |
|  Closing Tables |  0.000014 |   0.000000 |         0.000000 |          NULL | NULL |
|  Freeing items |  0.000006 |   0.000000 |         0.000000 |          NULL | NULL |
|  Waiting for query Cache lock |  0.000002 |   0.000000 |         0.000000 |          NULL | NULL |
|  Freeing items |  0.000045 |   0.000000 |         0.000000 |          NULL | NULL |
|  Waiting for query Cache lock |  0.000002 |   0.000000 |         0.000000 |          NULL | NULL |
|  Freeing items |  0.000002 |   0.000000 |         0.000000 |          NULL | NULL |
|  Storing result in query cache |  0.000003 |   0.000000 |         0.000000 |          NULL | NULL |
|  Logging Slow Query |  0.000003 |   0.000000 |         0.000000 |          NULL | NULL |
|  Cleaning Up |  0.000014 |   0.000000 |         0.000000 |          NULL | NULL |
+--------------------------------+-----------+-----------+------------+--------------+---------------+
Rows in Set, 1 Warning (0.00 sec)

SHOW PROFILES Syntax
SHOW profile [Type [, type] ...]
[for QUERY N]
[LIMIT row_count [offset offset]]
Type:
All
  | BLOCK IO
  | CONTEXT Switches
  | CPU
  | IPC
  | MEMORY
  | PAGE faults
  | SOURCE
  | SWAPS
meaning of type:
All displays all information
Block IO displays counts for BLOCK input and output operations
Context switches displays counts for voluntary and involuntary context switches
CPU displays user and system CPU usage times
IPC displays counts for messages sent and received
MEMORY is not currently implemented
page faults displays counts for major and minor page faults
source displays the names of functions from the SOURCE code, together with the name and line number of the file in WHI Ch The function occurs
SWAPS Displays swap counts

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.