mysql性能分析show profile/show profiles
MySQL性能分析show profiles
show profile 和 show profiles 语句可以展示当前会话(退出session后,profiling重置为0) 中执行语句的资源使用情况。
Profiling 功能由MySQL会话变量 : profiling控制,默认是OFF.关闭状态。select @@profiling; 或者show variables like '%profi%';
mysql> select @@profiling;
+-------------+
| @@profiling |
+-------------+
| |
+-------------+
Profiling是针对进程(process)而非线程(threads),因此运行在服务器上的其他服务进程可能会影响分析结果。Profiling 信息收集依赖于调用 系统方法 getrusage().因此Windows系统不适用。
开启Profiling功能:
mysql> set profiling = 1;
Query OK, 0 rows affected, 1 warning (0.00 sec)
退出会话后,Profiling功能自动关闭。
语句使用:
show profiles :列表,显示最近发送到服务器上执行的语句的资源使用情况.显示的记录数由变量:profiling_history_size 控制,默认15条。
mysql> show profiles;
+----------+------------+-------------------------------+
| Query_ID | Duration | Query |
+----------+------------+-------------------------------+
| 1 | 0.00371475 | show variables like '%profi%' |
| 2 | 0.00005700 | show prifiles |
| 3 | 0.00011775 | SELECT DATABASE() |
| 4 | 0.00034875 | select * from student |
+----------+------------+-------------------------------+
show profile: 展示最近一条语句执行的详细资源占用信息,默认显示 Status和Duration两列
mysql> show profile;
+----------------------+----------+
| Status | Duration |
+----------------------+----------+
| starting | 0.000054 |
| checking permissions | 0.000007 |
| Opening tables | 0.000116 |
| init | 0.000019 |
| System lock | 0.000009 |
| optimizing | 0.000004 |
| statistics | 0.000011 |
| preparing | 0.000010 |
| executing | 0.000002 |
| Sending data | 0.000061 |
| end | 0.000005 |
| query end | 0.000006 |
| closing tables | 0.000006 |
| freeing items | 0.000031 |
| cleaning up | 0.000010 |
+----------------------+----------+
show profile 还可根据 show profiles 列表中的 Query_ID ,选择显示某条记录的性能分析信息。
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
}
实例:
Examples:
mysql> SELECT @@profiling;
+-------------+
| @@profiling |
+-------------+
| 0 |
+-------------+
1 row in set (0.00 sec) mysql> SET profiling = 1;
Query OK, 0 rows affected (0.00 sec) mysql> DROP TABLE IF EXISTS t1;
Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> CREATE TABLE T1 (id INT);
Query OK, 0 rows affected (0.01 sec) mysql> SHOW PROFILES;
+----------+----------+--------------------------+
| Query_ID | Duration | Query |
+----------+----------+--------------------------+
| 0 | 0.000088 | SET PROFILING = 1 |
| 1 | 0.000136 | DROP TABLE IF EXISTS t1 |
| 2 | 0.011947 | CREATE TABLE t1 (id INT) |
+----------+----------+--------------------------+
3 rows in set (0.00 sec) mysql> SHOW PROFILE;
+----------------------+----------+
| Status | Duration |
+----------------------+----------+
| checking permissions | 0.000040 |
| creating table | 0.000056 |
| After create | 0.011363 |
| query end | 0.000375 |
| freeing items | 0.000089 |
| logging slow query | 0.000019 |
| cleaning up | 0.000005 |
+----------------------+----------+
7 rows in set (0.00 sec) mysql> SHOW PROFILE FOR QUERY 1;
+--------------------+----------+
| Status | Duration |
+--------------------+----------+
| query end | 0.000107 |
| freeing items | 0.000008 |
| logging slow query | 0.000015 |
| cleaning up | 0.000006 |
+--------------------+----------+
4 rows in set (0.00 sec) mysql> SHOW PROFILE CPU FOR QUERY 2;
+----------------------+----------+----------+------------+
| Status | Duration | CPU_user | CPU_system |
+----------------------+----------+----------+------------+
| checking permissions | 0.000040 | 0.000038 | 0.000002 |
| creating table | 0.000056 | 0.000028 | 0.000028 |
| After create | 0.011363 | 0.000217 | 0.001571 |
| query end | 0.000375 | 0.000013 | 0.000028 |
| freeing items | 0.000089 | 0.000010 | 0.000014 |
| logging slow query | 0.000019 | 0.000009 | 0.000010 |
| cleaning up | 0.000005 | 0.000003 | 0.000002 |
+----------------------+----------+----------+------------+
7 rows in set (0.00 sec)
mysql性能分析show profile/show profiles的更多相关文章
- MySQL性能分析及explain的使用
MySQL性能分析及explain用法的知识 1.使用explain语句去查看分析结果 如explain select * from test1 where id=1;会出现:id selectty ...
- MySQL性能分析及explain的使用说明
1.使用explain语句去查看分析结果 如explain select * from test1 where id=1;会出现:id selecttype table type possible_k ...
- MySQL性能分析和优化-part 1
MySQL性能优化 平时我们在使用MySQL的时候,怎么评估系统的运行状态,怎么快速定位系统瓶颈,又如何快速解决问题呢? 本文总结了多年来MySQL优化的经验,系统介绍MySQL优化的方法. OS性能 ...
- Python性能分析工具Profile
Python性能分析工具Profile 代码优化的前提是需要了解性能瓶颈在什么地方,程序运行的主要时间是消耗在哪里,对于比较复杂的代码可以借助一些工具来定位,python 内置了丰富的性能分析工具,如 ...
- MySQL性能分析, mysql explain执行计划详解
MySQL性能分析 MySQL性能分析及explain用法的知识是本文我们主要要介绍的内容,接下来就让我们通过一些实际的例子来介绍这一过程,希望能够对您有所帮助. 1.使用explain语句去查看分析 ...
- mysql性能分析工具
一.EXPALIN 在SQL语句之前加上EXPLAIN关键字就可以获取这条SQL语句执行的计划 那么返回的这些字段是什么呢? 我们先关心一下比较重要的几个字段: 1. select_type 查询类型 ...
- mysql性能分析-------profiling和explain
1. profiling之性能分析 MySQL5.0.37版本以上支持了Profiling – 官方手册.此工具可用来查询 SQL 会执行多少时间,System lock和Table lock 花多少 ...
- MySQL性能分析(转)
第一步:检查系统的状态 通过操作系统的一些工具检查系统的状态,比如CPU.内存.交换.磁盘的利用率.IO.网络,根据经验或与系统正常时的状态相比对,有时系统表面上看起来看空闲,这也可能不是一个正常的状 ...
- MySQL性能分析、及调优工具使用详解
本文汇总了MySQL DBA日常工作中用到的些工具,方便初学者,也便于自己查阅. 先介绍下基础设施(CPU.IO.网络等)检查的工具: vmstat.sar(sysstat工具包).mpstat.op ...
随机推荐
- session_id 生成原理
PHPSESSID生成 生成规则是根据hash_func散列来生成的,相关的参数有: - 客户端IP - 当前时间(秒) - 当前时间(微妙) - PHP自带的随机数生产器 hash_func是php ...
- udp协议和socketserver模块
#基于udp协议通讯的套接字# 数据报协议# 一个recvfrom对应一个sendto 一一对应 无粘包产生 # 服务端:# import socket# server=socket.socket(s ...
- 2019-03-07-day006-小数据池
01 昨日内容回顾 字典: 映射,{} 键值对的形式存储,容器型数据类型,key 唯一的,可哈希的,value任意数据类型,对象. 3.6之前无序的, 3.6之后,有序的(第一次创建字典的顺序) 特点 ...
- 判断input checkbox选中
$("#chexk").get(0).checked $("#chexk").is(':checked')
- python day10作业
- 【Python】数字驱动
#练习1:打开3个网址,每个等3秒钟 urls.txt: http://www.baidu.com http://www.sogou.com http://www.sohu.com main.py: ...
- 您应该将报表从Excel转换为Power BI的8个原因
传统上,Microsoft Excel是企业的首选报告工具,但Power BI为企业提供了强大的分析和报告功能.通过快速实验可视化,广泛数据集的统计功能和计算,以及快速重组字段动态获得答案的能力,很明 ...
- C++中输出字符到文本文档
#include <iostream> #include <fstream> //ofstream类的头文件 using namespace std; int main() { ...
- js 下载文件的操作方法
https://blog.csdn.net/zhoumengshun/article/details/71405963
- Spark各个版本新特性
后续会添加spark生态系统中各个组件的兼容支持情况... Spark2.0.0 * 2016-07-27正式发布 * 它是2.x版本线的上的第一个版本. * 300位contributors的超过2 ...