一、查看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参数的更多相关文章

  1. MySQL之profiling性能分析(在5.6.14版本被丢弃)

    官方建议使用information_schema.profiling. 原因是show profile 输出了查询执行的每个步骤及其花费的时间,但是结果很难快速确定哪个步骤花费的时间最多,因为输出是按 ...

  2. MySQL数据库实例参数对比脚本

    如何对比两个MySQL实例的参数情况,生产中常会有这样的需求,最近写了个python脚本,可基本实现该需求. 脚本 #!/usr/bin/python import MySQLdb,sys def f ...

  3. MySQL 各种超时参数的含义

    MySQL 各种超时参数的含义 今日在查看锁超时的设置时,看到show variables like '%timeout%';语句输出结果中的十几种超时参数时突然想整理一下,不知道大家有没有想过,这么 ...

  4. mysql命令行参数(转)

    MySQL命令行参数 Usage: mysql [OPTIONS] [database] //命令方式  -?, --help //显示帮助信息并退出  -I, --help //显示帮助信息并退出  ...

  5. mysql 命令行参数

    MySQL命令行参数 Usage: mysql [OPTIONS] [database] //命令方式  例如: mysql -h${HOSTNAME}  -P${PORT}  -u${USERNAM ...

  6. Mysql常用show命令,show variables like xxx 详解,mysql运行时参数

    MySQL中有很多的基本命令,show命令也是其中之一,在很多使用者中对show命令的使用还容易产生混淆,本文汇集了show命令的众多用法. 详细: http://dev.mysql.com/doc/ ...

  7. MySQL 有输入输出参数的存储过程实例

    1.MySQL 有输入输出参数的存储过程实例 DELIMITER // DROP PROCEDURE IF EXISTS `test`.`p_getvalue` // CREATE PROCEDURE ...

  8. MySql 链接url 参数详解

    最近 整理了一下网上关于MySql 链接url 参数的设置,有不正确的地方希望大家多多指教: mysql JDBC URL格式如下: jdbc:mysql://[host:port],[host:po ...

  9. MySQL复制相关参数详解

    MySQL复制相关参数详解 作者:尹正杰  版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.复制相关系统变量 1>.server_id 是必须设置在master和每个slave上的唯一标 ...

  10. MySQL中binlog参数:binlog_rows_query_log_events-记录具体的SQL【转】

    在使用RBR也就是行格式的时候,去解析binlog,需要逆向才能分析出对应的原始SQL是什么,而且,里面对应的是每一条具体行变更的内容.当然,你可以开启general log,但如果我们需要的只是记录 ...

随机推荐

  1. 基于卷积神经网络的MAE自监督方法

    本文分享自华为云社区<基于卷积神经网络的MAE自监督方法>,作者: Hint . 图像自监督预训练算法是近年来的重要研究方向,MAE是其中基于ViT实现的代表性方法,学习到了鲁棒的视觉特征 ...

  2. IDApython的学习

    IDApython的学习 我的IDA情况:IDA7.7,idapython3.8 这个可以作为文件导入和命令行内输入,我一般习惯命令行 这里要注意是python不是IDC 访问原数据 idc.get_ ...

  3. MIT6.s081/6.828 lectrue5/6:System call entry/exit 以及 Lab4 心得

    这篇博客主要复习 lecture05:GDB calling conentions 和 lecture06:System call entry/exit 的内容,外加 Lab4:traps 的心得 前 ...

  4. AI绘画:StableDiffusion制作AI赛博机车图保姆级教程

    本教程收集于:AIGC从入门到精通教程汇总 如果你具备Stable Diffusion的基础知识,那制作AI赛博机车图会更为顺畅.即便没有这个基础,只要严格按照教程的步骤执行,也能成功制作出来. 本教 ...

  5. CentOS 内网YUM源配置使用

    YUM介绍 yum,是Yellow dog Updater, Modified 的简称,是杜克大学为了提高RPM 软件包安装性而开发的一种软件包管理器.起初是由yellow dog 这一发行版的开发者 ...

  6. shopee商品详情接口的应用

    Shopee是东南亚和台湾地区最大的电子商务平台之一,成立于2015年,目前覆盖6个国家和地区.作为一家新兴电商平台,Shopee拥有快速增长的销售额和庞大的用户群体,为开发者提供了丰富的商业机会.其 ...

  7. Vika and Her Friends

    Smiling & Weeping ----早知道思念那么浓烈,不分手就好了 题目链接:Problem - A - Codeforces 题目大意:有n个Vika的朋友在一个n*m的方格中去捉 ...

  8. Longest Divisors Interval

    Smiling & Weeping ----总有一个人, 一直住在心底, 却消失在生活里. Given a positive integer n, find the maximum size ...

  9. Solution -「九省联考 2018」劈配

    Description Link. 一年一度的综艺节目<中国新代码>又开始了.Zayid 从小就梦想成为一名程序员,他觉得这是一个展示自己的舞台,于是他毫不犹豫地报名了. 轻车熟路的 Za ...

  10. Jenkins 命令执行 -- jetty 敏感信息泄露 --(CVE-2021-2816)&&(CVE-2017-1000353)&&(CVE-2018-1000861)

    Jenkins 命令执行 -- jetty 敏感信息泄露 --(CVE-2021-2816)&&(CVE-2017-1000353)&&(CVE-2018-100086 ...