Home Database Mysql Tutorial mysql性能调试工具profile_MySQL

mysql性能调试工具profile_MySQL

Jun 01, 2016 pm 01:02 PM
tool performance

我一直在找mysql中有没有类似Oracle 10046类似的工具,可以看到SQL执行的时间消耗在哪里。终于在网上找到一个profile,使用一些,觉得不错。

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 是看第1条执行的SQL语句
+--------------------------------+----------+----------+------------+--------------+---------------+
| 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 |
+--------------------------------+----------+----------+------------+--------------+---------------+
26 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 是看第2条执行的SQL语句
+--------------------------------+-----------+-----------+------------+--------------+---------------+
| 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 |
+--------------------------------+-----------+-----------+------------+--------------+---------------+
28 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
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 which the function occurs
SWAPS displays swap counts

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Apr 04, 2025 pm 11:54 PM

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

Does H5 page production require continuous maintenance? Does H5 page production require continuous maintenance? Apr 05, 2025 pm 11:27 PM

The H5 page needs to be maintained continuously, because of factors such as code vulnerabilities, browser compatibility, performance optimization, security updates and user experience improvements. Effective maintenance methods include establishing a complete testing system, using version control tools, regularly monitoring page performance, collecting user feedback and formulating maintenance plans.

How to achieve gap effect on the card and coupon layout with gradient background? How to achieve gap effect on the card and coupon layout with gradient background? Apr 05, 2025 am 07:48 AM

Realize the gap effect of card coupon layout. When designing card coupon layout, you often encounter the need to add gaps on card coupons, especially when the background is gradient...

Why are the purple slashed areas in the Flex layout mistakenly considered 'overflow space'? Why are the purple slashed areas in the Flex layout mistakenly considered 'overflow space'? Apr 05, 2025 pm 05:51 PM

Questions about purple slash areas in Flex layouts When using Flex layouts, you may encounter some confusing phenomena, such as in the developer tools (d...

Why does negative margins not take effect in some cases? How to solve this problem? Why does negative margins not take effect in some cases? How to solve this problem? Apr 05, 2025 pm 10:18 PM

Why do negative margins not take effect in some cases? During programming, negative margins in CSS (negative...

How to obtain real-time application and viewer data on the 58.com work page? How to obtain real-time application and viewer data on the 58.com work page? Apr 05, 2025 am 08:06 AM

How to obtain dynamic data of 58.com work page while crawling? When crawling a work page of 58.com using crawler tools, you may encounter this...

JavaScript code line break: How to handle long string and object attribute access gracefully? JavaScript code line break: How to handle long string and object attribute access gracefully? Apr 05, 2025 am 08:03 AM

Detailed explanation of JavaScript code line-breaking skills When writing JavaScript code, we often encounter a line of code that is too long, which not only affects the readability of the code...

Why do negative margins not take effect in some cases? Why do negative margins not take effect in some cases? Apr 05, 2025 pm 04:09 PM

Why do negative margins not take effect in some cases? When using CSS to layout web pages, you often encounter negative margins (negative...

See all articles