性能测试Mysql之profiling参数
一、查看profiling状态
mysql> select @@profiling;
0:表示为关闭
1:表示开启
二、开启 profiling
mysql> SET profiling=1;
三、show profiles 命令
mysql> show profiles;
+----------+------------+--------------------------------------------+
| Query_ID | Duration | Query |
+----------+------------+--------------------------------------------+
| 1 | 0.00007100 | select profiling |
| 2 | 0.00010800 | select @@profiling |
| 3 | 0.00004875 | show profiling |
| 4 | 0.00031000 | show tables |
| 5 | 0.00015800 | select count(1) from emp |
| 6 | 0.00017575 | select count(1) from dept |
| 7 | 0.00021650 | select * from emp |
| 8 | 0.00017050 | select * from emp where location_id='1800' |
+----------+------------+--------------------------------------------+
8 rows in set, 1 warning (0.00 sec)
查看所有语句消耗的具体时间(Duration)和使用的查询(Query )
四、单query获取详细的profile的信息
语法:
show profile for query query_id
查看具体的query_ID所经历的过程以及消耗的资源详细分析报告
1. 查询 Query_ID=5信息
mysql> show profile for query 5;
+----------------------+----------+
| Status | Duration |
+----------------------+----------+
| starting | 0.000041 |
| checking permissions | 0.000004 |
| Opening tables | 0.000011 |
| init | 0.000009 |
| System lock | 0.000005 |
| optimizing | 0.000003 |
| statistics | 0.000007 |
| preparing | 0.000006 |
| executing | 0.000001 |
| Sending data | 0.000026 |
| end | 0.000002 |
| query end | 0.000004 |
| closing tables | 0.000004 |
| freeing items | 0.000006 |
| logging slow query | 0.000025 |
| cleaning up | 0.000007 |
+----------------------+----------+
16 rows in set, 1 warning (0.00 sec)
2. 查询 Query_ID=5的cup、io信息
cpu
mysql> show profile cpu for query 5;
+----------------------+----------+----------+------------+
| Status | Duration | CPU_user | CPU_system |
+----------------------+----------+----------+------------+
| starting | 0.000041 | 0.000023 | 0.000014 |
| checking permissions | 0.000004 | 0.000003 | 0.000002 |
| Opening tables | 0.000011 | 0.000006 | 0.000004 |
| init | 0.000009 | 0.000006 | 0.000003 |
| System lock | 0.000005 | 0.000003 | 0.000002 |
| optimizing | 0.000003 | 0.000001 | 0.000001 |
| statistics | 0.000007 | 0.000004 | 0.000002 |
| preparing | 0.000006 | 0.000004 | 0.000002 |
| executing | 0.000001 | 0.000001 | 0.000001 |
| Sending data | 0.000026 | 0.000016 | 0.000009 |
| end | 0.000002 | 0.000001 | 0.000001 |
| query end | 0.000004 | 0.000002 | 0.000001 |
| closing tables | 0.000004 | 0.000003 | 0.000002 |
| freeing items | 0.000006 | 0.000003 | 0.000002 |
| logging slow query | 0.000025 | 0.000016 | 0.000009 |
| cleaning up | 0.000007 | 0.000004 | 0.000003 |
+----------------------+----------+----------+------------+
CPU_user:当前用户占用的 CPU;
CPU_system:当前系统占用的CPU。
io:
mysql> show profile block io for query 5;
±--------------±---------±-------------±--------------+
| Status | Duration | Block_ops_in | Block_ops_out |
±--------------±---------±-------------±--------------+
| starting | 0.000036 | 0 | 0 |
| freeing items | 0.000009 | 0 | 0 |
| cleaning up | 0.000004 | 0 | 0 |
±--------------±---------±-------------±--------------+
3 rows in set, 1 warning (0.00 sec)
查看所有参数,使用如下命令:
show profile all for query 5
性能测试Mysql之profiling参数的更多相关文章
- MySQL之profiling性能分析(在5.6.14版本被丢弃)
官方建议使用information_schema.profiling. 原因是show profile 输出了查询执行的每个步骤及其花费的时间,但是结果很难快速确定哪个步骤花费的时间最多,因为输出是按 ...
- MySQL数据库实例参数对比脚本
如何对比两个MySQL实例的参数情况,生产中常会有这样的需求,最近写了个python脚本,可基本实现该需求. 脚本 #!/usr/bin/python import MySQLdb,sys def f ...
- MySQL 各种超时参数的含义
MySQL 各种超时参数的含义 今日在查看锁超时的设置时,看到show variables like '%timeout%';语句输出结果中的十几种超时参数时突然想整理一下,不知道大家有没有想过,这么 ...
- mysql命令行参数(转)
MySQL命令行参数 Usage: mysql [OPTIONS] [database] //命令方式 -?, --help //显示帮助信息并退出 -I, --help //显示帮助信息并退出 ...
- mysql 命令行参数
MySQL命令行参数 Usage: mysql [OPTIONS] [database] //命令方式 例如: mysql -h${HOSTNAME} -P${PORT} -u${USERNAM ...
- Mysql常用show命令,show variables like xxx 详解,mysql运行时参数
MySQL中有很多的基本命令,show命令也是其中之一,在很多使用者中对show命令的使用还容易产生混淆,本文汇集了show命令的众多用法. 详细: http://dev.mysql.com/doc/ ...
- MySQL 有输入输出参数的存储过程实例
1.MySQL 有输入输出参数的存储过程实例 DELIMITER // DROP PROCEDURE IF EXISTS `test`.`p_getvalue` // CREATE PROCEDURE ...
- MySql 链接url 参数详解
最近 整理了一下网上关于MySql 链接url 参数的设置,有不正确的地方希望大家多多指教: mysql JDBC URL格式如下: jdbc:mysql://[host:port],[host:po ...
- MySQL复制相关参数详解
MySQL复制相关参数详解 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.复制相关系统变量 1>.server_id 是必须设置在master和每个slave上的唯一标 ...
- MySQL中binlog参数:binlog_rows_query_log_events-记录具体的SQL【转】
在使用RBR也就是行格式的时候,去解析binlog,需要逆向才能分析出对应的原始SQL是什么,而且,里面对应的是每一条具体行变更的内容.当然,你可以开启general log,但如果我们需要的只是记录 ...
随机推荐
- 部分 Linux 换国内源
Centos 8 / Redhat 8 换国内源 操作步骤 先把原本的官方 yum 源 删除 或 备份 cd /etc/yum.repos.d/ 备份(Redhat 同理) rename repo r ...
- 【Azure App Service】为部署在App Service上的PHP应用开启JIT编译器
问题描述 在App Service for linux上创建一个PHP应用,通过 phpinfo() 查看PHP的扩展设置,发现JIT没有被开启, jit_buffer_size 大小为0. 那么,在 ...
- 程序员视角下的API数据接口对接指南
在当今互联网时代,许多应用程序和网站都需要使用第三方的API接口来获取数据.API(Application Programming Interface)允许不同的应用程序之间进行数据交互,从而提高 ...
- Nexus搭建maven仓库并使用
一.基本介绍 参考:https://www.hangge.com/blog/cache/detail_2844.html https://blog.csdn.net/zhuguanbo/article ...
- Webpack性能优化 SplitChunksPlugin的使用详解
使用前景 在vue.react等使用webpack为项目打包工具的前端项目,在开发过程中,随着项目功能的逐渐增加,项目整体体积的不断增加,打包的时长和打包后部署的项目体积也在不停的增长,这样可能会导致 ...
- 「tjoi 2018」智力竞赛
link. 这题数据应该蛮水的,直接把大于二分值的点去掉实际上应该是有问题的.然而题解区里都写的是这种做法,所以这里主要对如何处理大于二分值的点做分析. 注意这里大于二分值的点的意义是「可以走,但走了 ...
- 「atcoder - ABC215G」Colorful Candies 2
link. 称题目中的 \(c_i\) 为 \(a_i\),令 \(c_i\) 为第 \(i\) 种颜色的出现次数,令 \(C\) 为颜色总数.固定 \(k\),令 \(t_i=1\),如果颜色 \( ...
- 7.4 通过API枚举进程权限
GetTokenInformation 用于检索进程或线程的令牌(Token)信息.Token是一个数据结构,其包含有关进程或线程的安全上下文,代表当前用户或服务的安全标识符和权限信息.GetToke ...
- c语言代码练习13
//打印九九乘法表#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> int main() { int x = 0; int y = ...
- .NET 8 RC 2 发布,将在11月14日发布正式版
微软2023-10-10 发布了 .NET 8 RC 2,下一站是.NET 8正式发布,就在下个月Net Conf 2023[1](11月14日)期间正式发布,我们也开始筹备第四届中国.NET开发者峰 ...