首页 > 数据库 >mysql使用sys和performance_schema查看慢查询

mysql使用sys和performance_schema查看慢查询

时间:2022-11-23 14:24:20浏览次数:48  
标签:latency exec sys mysql performance total schema

select
	schema_name,
	format_pico_time(total_latency) total_latency,
	exec_count,
	format_pico_time(total_latency/exec_count) latency_per_call,
	query_sample_text 
from
	sys.x$statements_with_runtimes_in_95th_percentile as t1
	join performance_schema.events_statements_summary_by_digest as t2 on t2.digest = t1.digest 
where
	schema_name not in ( 'performance_schema', 'sys' ) 
order by
	( total_latency / exec_count ) desc; 

  

select * from sys.statement_analysis where db not in ('performance_schema', 'sys') order by avg_latency desc;	

  

标签:latency,exec,sys,mysql,performance,total,schema
From: https://www.cnblogs.com/abclife/p/16918117.html

相关文章

  • Mysql索引
    innodb引擎索引数据结构:B+树,原型为N叉树,在innodb中N大约为1200,树高为4时,大约可以存1200的3次方的数据,约为17亿(树根的数据块一般在内存中,10亿数据的表上查一个数值,只需要查......
  • Sysbench安装最新版本(Debian/Ubuntu/RHEL/CentOS/Fedora)
    重要说明:sysbench在Git上的各个版本二进制包下载路径:https://github.com/akopytov/sysbench/releases如下的2种安装方式,任选一种即可第一种:Quickinstallinstructions:......
  • 通过Python实现MySQL和PG数据比对
    生产上,有个需要从MySQL异构复制数据到PG中的需求。数据同步组件用的是go-mysql-postgres(两位前同事基于社区开源的go-mysql-elasticsearch上做的PG功能补丁)。目前测试环境......
  • mysql破解root密码
    #设置免密登录echoskip-grant-tables>>/etc/my.cnfsystemctlrestartmysqld#设置密码为空mysql-e'usemysql;updateusersetauthentication_string=""where......
  • 安装mysql服务添加到systemctl服务当中
    1、https://www.cnblogs.com/dahuo/p/16014689.html把mysqld添加至systemctl进行管理 #复制过去后,会sytemctl会自动识别的 cp/usr/local/mysql/support-f......
  • mysql 报错 1292 - Truncated incorrect DECIMAL value
    数据库维护之时,报错1292sql如下update表1leftjoin表2on表1.关联字段=表2.关联字段set表1.更新字段=表2.字段where表2.字段!=''and表2.字段!='#VALU......
  • MySQL UTF-8 编码下使中文排序生效的办法
    1.查询的时候是加入转换函数SELECT`hotel_name`FROM`hotel_base`ORDERBYconvert(`hotel_name`USINGgbk)COLLATEgbk_chinese_ci 2.设置单个需要中文排序字段的......
  • MySQL数据库初体验
    一.数据库的基本概念1、数据(Data)•描述事物的符号记录•包括数字,文字,图形,图像,声音,档案记录等•以“记录”形式按统一的格式进行存储2、表•将不同的记录组织在......
  • mysql初始化设置密码遇到的问题
    关于这个问题是在mysql初始化时,使用临时密码,修改自定义密码时,由于自定义密码比较简单,就出现了不符合密码策略的问题。解决办法:1.进入mysql输入命令:mysql-root-p2、查......
  • MySQL的概念、编译安装,以及自动补全
    一.数据库的基本概念1、数据(Data)•描述事物的符号记录•包括数字,文字,图形,图像,声音,档案记录等•以“记录”形式按统一的格式进行存储2、表•将不同的记录组织在一......