information_schema.profiling可以用来分析每一条SQL在它执行的各个阶段的用时,注意这个表是session 级的,也就是说如果session1 开启了它;session2没有开启

这个情况下session2 去查询只会返回一个空表

1、set @@ssesion.profiling=1 可以开启information_schema.profiling相关监测

2、information_schema.profiling 表的常用列

  1、query_id              :查询id 用于标记不同的查询

  2、seq                 :一个查询内部执行的步骤

  3、state                :各个步骤的状态

  4、duration              :各个步骤持续的时间

  5、cpu_user              :用户空间的cpu 使用量

  6、cpu_system            :内核空间的cpu 使用量

  7、swaps               :swap 发生的次数

3、例子:

  1、开启监测

set @@ssesion.profiling=1;

  2、执行查询

select * from tempdb.t;

  3、关闭监测

set @@ssesion.profiling=0;

  4、查询监测到的数据

 select
-> query_id, -- 查询id 它用于标识一个查询
-> seq, -- 显示序号
-> (select sum(duration) from information_schema.profiling as innert where innert.query_id = outert.query_id) as total_cost , -- 总用时in seconds
-> state,-- 状态
-> duration, -- 持续时间
-> cpu_user, -- 用户空间的cpu 使用量
-> cpu_system, -- 内核空间的cpu 使用量
-> -- context_voluntary, -- 自愿上下文切换
-> -- context_involuntary, -- 非自愿上下文切换
-> block_ops_in, -- 块调入次数
-> block_ops_out, -- 块调出次数
-> swaps -- 发生swap 的次数
-> from
-> information_schema.profiling as outert
->
-> order by
-> seq;
+----------+-----+------------+----------------------+----------+----------+------------+--------------+---------------+-------+
| query_id | seq | total_cost | state | duration | cpu_user | cpu_system | block_ops_in | block_ops_out | swaps |
+----------+-----+------------+----------------------+----------+----------+------------+--------------+---------------+-------+
| 1 | 2 | 0.001984 | starting | 0.000058 | 0.000000 | 0.000000 | 0 | 0 | 0 |
| 1 | 3 | 0.001984 | checking permissions | 0.000010 | 0.000000 | 0.000000 | 0 | 0 | 0 |
| 1 | 4 | 0.001984 | Opening tables | 0.000033 | 0.000000 | 0.000000 | 0 | 0 | 0 |
| 1 | 5 | 0.001984 | init | 0.000018 | 0.000000 | 0.000000 | 0 | 0 | 0 |
| 1 | 6 | 0.001984 | System lock | 0.000012 | 0.000000 | 0.000000 | 0 | 0 | 0 |
| 1 | 7 | 0.001984 | optimizing | 0.000006 | 0.000000 | 0.000000 | 0 | 0 | 0 |
| 1 | 8 | 0.001984 | statistics | 0.000014 | 0.000000 | 0.000000 | 0 | 0 | 0 |
| 1 | 9 | 0.001984 | preparing | 0.000013 | 0.000000 | 0.000000 | 0 | 0 | 0 |
| 1 | 10 | 0.001984 | executing | 0.000003 | 0.000000 | 0.000000 | 0 | 0 | 0 |
| 1 | 11 | 0.001984 | Sending data | 0.000130 | 0.000000 | 0.000000 | 0 | 0 | 0 |
| 1 | 12 | 0.001984 | end | 0.000009 | 0.000000 | 0.000000 | 0 | 0 | 0 |
| 1 | 13 | 0.001984 | query end | 0.000008 | 0.000000 | 0.000000 | 0 | 0 | 0 |
| 1 | 14 | 0.001984 | closing tables | 0.001613 | 0.002000 | 0.000000 | 0 | 0 | 0 |
| 1 | 15 | 0.001984 | freeing items | 0.000037 | 0.000000 | 0.000000 | 0 | 0 | 0 |
| 1 | 16 | 0.001984 | cleaning up | 0.000020 | 0.000000 | 0.000000 | 0 | 0 | 0 |
+----------+-----+------------+----------------------+----------+----------+------------+--------------+---------------+-------+

information_schema.profiling学习的更多相关文章

  1. INFORMATION_SCHEMA.PROFILING

    24.18 The INFORMATION_SCHEMA PROFILING Table PROFILING表提供了语句分析信息. 其内容对应于SHOW PROFILES和SHOW PROFILE语句 ...

  2. mysql执行update报错 Err] 1055 - 'information_schema.PROFILING.SEQ' isn't in GROUP BY

    mysql执行update报错 Err] 1055 - 'information_schema.PROFILING.SEQ' isn't in GROUP BY 今天开发的同事发来如下错误信息,最最简 ...

  3. mysql遇见contains nonaggregated column 'information_schema.PROFILING.SEQ'异常

    报错如下:[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggrega ...

  4. 解决mysql报错:- Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ'

    mysql执行报错: - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated c ...

  5. mysql [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent on columns in GRO

    [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated c ...

  6. [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ'

    在Navicat Premium中执行Mysql的一条删除语句,虽然执行成功了,却提示已下错误: 受影响的行: 时间: .005s of ORDER BY clause is not in GROUP ...

  7. MySQL- [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent on columns in GR

    新建的mysql,在查询时报异常信息,虽然有正常执行结果. [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY claus ...

  8. information_schema.referential_constraints 学习

    information_schema.referential_constraints 表用于查看外键约束 1.information_schema.referential_constraints表的常 ...

  9. information_schema.optimizer_trace学习

    information_schema.optimizer_trace 用于追踪优化器的优化过程:通常来说这张表中是没有数据的,要想开户追踪要把 @@session.optimizer_trace='e ...

随机推荐

  1. 必须弄懂的495个C语言问题

    1.1 我如何决定使用那种整数类型? 如果需要大数 值(大于32, 767 或小于¡32, 767), 使用long 型.否则, 如果空间很重要(如有大数组或很多结构), 使用short 型.除此之外 ...

  2. Apache RewriteRule QSA 什么意思

    看到下面这段代码: RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] The Rewrit ...

  3. paip.Adblock屏蔽规则保存位置以及修理恢复

    paip.Adblock屏蔽规则保存位置以及修理恢复 作者Attilax ,  EMAIL:1466519819@qq.com  来源:attilax的专栏 地址:http://blog.csdn.n ...

  4. linux下tcpdump命令详解

    简介 用简单的话来定义tcpdump,就是:dump the traffic on a network,根据使用者的定义对网络上的数据包进行截获的包分析工具. tcpdump可以将网络中传送的数据包的 ...

  5. ios 以NSObject为父类的各类间继承关系

  6. 【Oracle】逻辑结构(TableSpace→Segment→Extent→Block)

     一.逻辑体系结构图 二.逻辑结构图组成介绍 从上表能够看出,一个数据库是由多个表空间(tablespace)组成,一个表空间又由多个段(segment)组成,一个段又由多个区(extent)组成 ...

  7. (3)选择元素——(5)为项目列表加样式(Styling list-item levels)

    Let's suppose that we want the top-level items, and only the top-level items, to be arranged horizon ...

  8. CI框架源代码阅读笔记3 全局函数Common.php

    从本篇開始.将深入CI框架的内部.一步步去探索这个框架的实现.结构和设计. Common.php文件定义了一系列的全局函数(一般来说.全局函数具有最高的载入优先权.因此大多数的框架中BootStrap ...

  9. 关于 linux ssh 的配置.

    一.禁止root用户远程登录: # cd /etc/ssh # vi sshd_config  将 permitRootLogin 后面的值改成 no 如下图: 然后再重启sshd服务即可,如下: # ...

  10. gradient杂谈

    工作中难免遇到某些小项目中没有设计的情况,这对于PS基础薄弱的我来说非常恐怖.无奈之下,只好自己自学UI方面的知识,但对于某些能用CSS实现的背景样式等,还是尽可能地用已经掌握的知识去实现.本文主要分 ...