当前位置: 首页 > news >正文

东莞 手机网站制作建站平台wp

东莞 手机网站制作,建站平台wp,网络销售渠道,公司网站成本MySQL语句执行耗时分析 MySQL Profile查看SQL执行各阶段耗时Performance Schema查看SQL执行各阶段耗时配置收集哪些用户的SQL执行信息开启SQL执行信息收集的相关特性执行目标SQL获取SQL执行的EVENT_ID获取SQL执行各阶段耗时 MySQL Profile查看SQL执行各阶段耗时 --开启SQL Pro…

MySQL语句执行耗时分析

  • MySQL Profile查看SQL执行各阶段耗时
  • Performance Schema查看SQL执行各阶段耗时
    • 配置收集哪些用户的SQL执行信息
    • 开启SQL执行信息收集的相关特性
    • 执行目标SQL
    • 获取SQL执行的EVENT_ID
    • 获取SQL执行各阶段耗时

MySQL Profile查看SQL执行各阶段耗时

--开启SQL Profiling
SQL> set profiling=1; --执行目标SQL
SQL> SELECT * FROM db.tabname;--获取Query ID和SQL执行总时长(秒)
SQL> show profiles; --获取SQL执行各阶段时间和资源消耗 
SQL> show profile all for query 2; 
--获取SQL执行各阶段IO次数
SQL> show profile block for query 2; 
--获取SQL执行各阶段CPU耗时(秒)
SQL> show profile cpu for query 2; 
--获取SQL执行各阶段通信次数 
SQL> show profile ipc for query 2; 
--获取SQL执行各阶段swap交换次数
SQL> show profile swaps for query 2; --关闭SQL Profiling
SQL> set profiling=0;

🦈See more in https://dev.mysql.com/doc/refman/8.0/en/show-profile.html

Performance Schema查看SQL执行各阶段耗时

MySQL Profile目前已被列为Deprecated,官方推荐使用Performance Schema替代。不过目前Performance Schema好像还不是很完善,只能查看SQL执行各阶段的耗时,而看不到CPU和IO等资源消耗(截止8.0.32)。

配置收集哪些用户的SQL执行信息

查看搜集哪些用户的SQL执行历史信息:

select * from performance_schema.setup_actors;

限制搜集SQL执行历史信息的用户为本地root用户连接(根据实际需求设置):

update performance_schema.setup_actors 
set enabled='NO', history='NO' 
where host='%' and user='%';insert into performance_schema.setup_actors (host,user,role,enabled,history) 
values('localhost','root','%','YES','YES');select * from performance_schema.setup_actors;

开启SQL执行信息收集的相关特性

确保setup_instruments中的相关特性已开启:

update performance_schema.setup_instruments 
set enabled='YES', TIMED='YES' 
where name like '%statement/%';update performance_schema.setup_instruments 
set enabled='YES', TIMED='YES' 
where name like '%stage/%';

确保setup_consumers中的相关特性已开启:

update performance_schema.setup_consumers 
set enabled='YES' where name like '%events_statements_%';update performance_schema.setup_consumers 
set enabled='YES' where name like '%events_stages_%';

执行目标SQL

SELECT * FROM employees.employees WHERE emp_no = 10001;

获取SQL执行的EVENT_ID

events_statements_history_long中获取执行SQL的EVENT_ID:

select event_id, truncate(timer_wait/1000000000000,6) as duration, sql_text 
from performance_schema.events_statements_history_long 
where sql_text like 'SELECT%';

获取SQL执行各阶段耗时

events_stages_history_long中获取SQL执行各阶段的耗时:

--以nesting_event_id匹配上面得到的event_id
select event_name as stage, truncate(timer_wait/1000000000000,6) as duration 
from performance_schema.events_stages_history_long 
where nesting_event_id=299;

🐬See more in https://dev.mysql.com/doc/refman/8.0/en/performance-schema-query-profiling.html

http://www.yayakq.cn/news/918881/

相关文章:

  • 邢台网站推广专业服务wordpress菜单下拉
  • 做网站的具体需求做动画 的 网站有哪些内容
  • 自动化东莞网站建设为企业做好服务优化营商环境
  • 网站充值提现公司账务怎么做网站页面创意
  • 可以做cps合作的棋牌网站6网站的经营推广
  • 如何注册公司网站域名网络公司做什么业务
  • 网站开发语言netseo是哪里
  • 西安建设和住房保障局网站地方网站运营教程
  • app展示网站模板html厦门网站设计公司推荐
  • 清远网站开发sohu做心悦腾龙光环的网站
  • 做企业网站合同怎么做淘宝客网站优化
  • 企业网站发布图片文章西安专业网站建设服务公司
  • 天津工程网站建设青岛建站公司推荐
  • 网站备案费用多少龙岩特色
  • 关于建设饮食与健康网站的意义学院网站建设的要求
  • php网站安装图解十堰网络推广培训
  • 免费的平面设计网站镇江网站建设工作室
  • 深圳专业网站建设公司个人免费网站建设教程
  • 哪建设网站网站建设项目的网络图
  • asp网站建设源码企业网站备案网址
  • 低价网站建设推广报价小程序免费开发
  • 深圳网站建设公司968网站开发招标文件范本
  • 免费弄空间的网站网站关键词优化软件效果
  • 福州公司网站建设_东莞市研发网站建设公司
  • 高端做网站公司哪家好wordpress安装教程
  • 六十岁一级a做爰片免费网站商丘做网站推广的公司
  • 珠海市区工商年报在哪个网站做淄博北京网站建设
  • 青岛高端网站设计logo生成
  • 游戏网站建设平台排版素材网站
  • 一般网站图片尺寸站长统计软件