mysql profiles清空_MYSQL 使用show profiles 分析性能

MYSQL 使用show profiles 分析性能

Show profiles是5.0.37之后添加的,要想使用此功能,要确保版本在5.0.37之后。如果要使用此功能,先查看mysql版本是否高于5.0.37

查看数据库版本:

mysql> select version(); +-----------+ | version() | +-----------+ | 5.7.9-log | +-----------+ 1 row in set (0.00 sec) 说明此版本mysql具有此功能。

打开分析工具:

set @@prifileing=1; 执行查询:

mysql> select uid from u_user_master where id_card like '%233%'; +-----+ | uid | +-----+ | 48 | | 62 | | 67 | | 68 | | 69 | | 140 | | 145 | | 146 | | 166 | +-----+ 9 rows in set (0.00 sec) 查看mysql性能

mysql> show profiles; +----------+------------+------------------------------------------------------------+ | Query_ID | Duration | Query | +----------+------------+------------------------------------------------------------+ | 1 | 0.00033300 | select uid from u_user_master where id_card like '%233%' | | 2 | 0.00005900 | show version() | | 3 | 0.00013300 | select version() | | 4 | 0.00041800 | select uid from u_user_master where id_card like '%233%' | +----------+------------+------------------------------------------------------------+ 4 rows in set, 1 warning (0.00 sec) 第二列表示查询所用的时间。

根据Query_ID 查看某个查询的详细时间耗费

mysql> show profile for query 4; +----------------------+----------+ | Status | Duration | +----------------------+----------+ | starting | 0.000071 | | checking permissions | 0.000007 | | Opening tables | 0.000016 | | init | 0.000023 | | System lock | 0.000020 | | optimizing | 0.000010 | | statistics | 0.000016 | | preparing | 0.000012 | | executing | 0.000003 | | Sending data | 0.000148 | | end | 0.000005 | | query end | 0.000006 | | closing tables | 0.000008 | | freeing items | 0.000020 | | logging slow query | 0.000041 | | cleaning up | 0.000012 | +----------------------+----------+ 16 rows in set, 1 warning (0.00 sec) 查看cpu、IO等信息

mysql> show profile block io, cpu for query 4; +----------------------+----------+----------+------------+--------------+---------------+ | Status | Duration | CPU_user | CPU_system | Block_ops_in | Block_ops_out | +----------------------+----------+----------+------------+--------------+---------------+ | starting | 0.000071 | 0.000065 | 0.000005 | 0 | 0 | | checking permissions | 0.000007 | 0.000005 | 0.000002 | 0 | 0 | | Opening tables | 0.000016 | 0.000016 | 0.000001 | 0 | 0 | | init | 0.000023 | 0.000021 | 0.000001 | 0 | 0 | | System lock | 0.000020 | 0.000009 | 0.000011 | 0 | 0 | | optimizing | 0.000010 | 0.000009 | 0.000002 | 0 | 0 | | statistics | 0.000016 | 0.000015 | 0.000001 | 0 | 0 | | preparing | 0.000012 | 0.000011 | 0.000001 | 0 | 0 | | executing | 0.000003 | 0.000001 | 0.000001 | 0 | 0 | | Sending data | 0.000148 | 0.000148 | 0.000001 | 0 | 0 | | end | 0.000005 | 0.000002 | 0.000002 | 0 | 0 | | query end | 0.000006 | 0.000006 | 0.000001 | 0 | 0 | | closing tables | 0.000008 | 0.000007 | 0.000001 | 0 | 0 | | freeing items | 0.000020 | 0.000008 | 0.000012 | 0 | 0 | | logging slow query | 0.000041 | 0.000022 | 0.000019 | 0 | 0 | | cleaning up | 0.000012 | 0.000011 | 0.000001 | 0 | 0 | +----------------------+----------+----------+------------+--------------+---------------+ 16 rows in set, 1 warning (0.00 sec)

作者:KevinWorld 链接:https://www.jianshu.com/p/7afcd5ba3708 來源:简书 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/291412.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

JSP使用JSON传递数据,注意避免中文乱码

JSP传递数据时不方便使用Java中的对象类型,一般使用JSON来传递对象。 在使用JSON时,前端js如下,注意指定dataType: var htmlobj $.ajax({ url:"chat.do",type:"POST", data:{sayingContent:$("#textarea…

【求助】AIX5.3主机下 memcached的内存使用异常

2019独角兽企业重金招聘Python工程师标准>>> AIX5.3主机下 memcached 内存增长到256M后,就不增长了(实际启动时设置的内存>2G); 测试发现在windows、Linux DLXEL02 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT…

MASA Framework - DDD设计(1)

DDD领域驱动设计是一个有关软件开发的方法论,它提出基于领域开发的开发模式,基于DDD理论,我们可以设计出高质量的软件模型。它围绕业务概念构建领域模型来控制业务的复杂度,解决软件难以理解和演化的问题。微服务微服务是一种架构…

LeetCode之Reverse String

1、题目: Write a function that takes a string as input and returns the string reversed. Example: Given s "hello", return "olleh". 2、代码实现: 代码实现1:public static String reverseString(String s) {if (s null) {…

linux第二课

linux第二课关机 halt shutdown重启 reboot运行终端 gnome-terminalsystem-config-date 日期与时间firefox http://www.baidu.com 火狐打开百度gedit 文件名 文本编辑器转载于:https://blog.51cto.com/2732951/1899825

mysql的indata文件_【数据分析】MySQL之不能导入本地文件“Loading local data is disable;”...

今天在使用"利用MySQL的命令行进行CSV文件的导入"时,遇到了这样一个问题:提示本地文件无法导入,必须要"同时获得客户端和服务器端的许可"。很难受,于是上网搜了一下教程,最后综合了以下这几个网站…

经典语录和思考总结

研发类  科学研究,搞设计的 技术类  工程技术,搞实施的 管理类  工商管理,人为管理,。。。 功成名就 成功并不是一蹴而就的,成功分为“成”和“功”两个阶段,只有积累“功”,才能促使“成…

Kubernetes 集群日志 和 EFK 架构日志方案

目录第一部分:Kubernetes 日志Node Level Logging AgentStreaming sidecar containerSidecar Logging AgentKubernetes Logging 是如何工作的Kubernetes Pod 日志存储位置Kubelet LogsKubernetes 容器日志格式Kubernetes 日志的类型Kubernetes Logging 架构Kubernet…

Android之EditText自定义边框和边框颜色(转载)

介绍一种比较常见的用法 第一步:准备两张图片大小一样,颜色不同的图片。图片名称分为:editbox_focus.png和editbox_normal.png 放入工程的drawable文件夹下。 第二步:在drawable文件下创建 my_edittext.xml文件 内容如下&#xff…

LeetCode之Hamming Distance

1、题目 The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calculate the Hamming distance. Note: 0 ≤ x, y < 231. Example: Input: x 1, y 4Output: 2Explanation…

python运行速度慢是解释器的原因_python为什么会运行慢

我们之前一定听有人说过&#xff0c;python的执行速度比其他语言慢。python会运行慢的原因&#xff1a;1、python是动态性语言不是静态性语言这是说在python程序执行的时候&#xff0c;编译器不知道变量的类型。图1.展示了C语言中的变量与python中变量的区别。在C中编译器知道变…

HDU1232 畅通工程

问题链接&#xff1a;HDU1232 畅通工程。 问题简述&#xff1a;输入n和m&#xff0c;分别表示城镇的数量和城镇间道路的数量。再输入m个数对s和d表示城镇s到d有道路连通。问还需要修多少条道路才能够把这些城镇都连通起来。 问题分析&#xff1a;这是一个有关图的连通性问题&am…

LeetCode之Keyboard Row

1、题目&#xff1a; Given a List of words, return the words that can be typed using letters of alphabeton only one rows of American keyboard like the image below.Example 1: Input: ["Hello", "Alaska", "Dad", "Peace"]…

微信公众平台多客服

微信公众平台官方推出多客服功能&#xff0c;商户在微信公众平台&#xff08;http://mp.weixin.qq.com&#xff09;开通人工客服权限以后&#xff0c;于“功能-多客服”中&#xff0c;添加客服。然后可以在电脑端上使用多客服接待。其使用方法如下。 1建立客服团队 商户在微信公…

C#中类的异常处理

欢迎您成为我的读者&#xff0c;希望这篇文章能给你一些帮助。前言日常编码过程中&#xff0c;最重要的技能不是说你学会使用很多最新的编程技术或者做出一个高大上的系统。而是你在写代码过程中&#xff0c;对异常的处理&#xff0c;是否系统可以稳定&#xff0c;健壮。对于异…

MongoDB常用操作

1.查看帮助命令 help db.yourColl.help(); db.youColl.find().help(); db.help()&#xff1a;显示数据库操作命令&#xff0c;里面有很多的命令 db.foo.help()&#xff1a;显示集合操作命令&#xff0c;同样有很多的命令&#xff0c;foo指的是当前数据库下&#xff0c;一个叫f…

Linus Torvalds: 成功的项目源于99%的汗水与1%的创新

2017年2月15日&#xff0c;在加利福尼亚州的开源领袖峰会上&#xff0c;由Linux基金会执行董事Jim Zemlin进行的一次采访中&#xff0c;Torvalds讨论了他如何管理Linux内核的开发以及他对工作的态度。\\\\Linus Torvalds认为&#xff0c;科技行业对创新的颂扬是一种自鸣得意&am…

LeetCode之Fizz Buzz

1、题目 Write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three a…

Large sum

聪明的办法是想&#xff1a;求前10位&#xff0c;那只要前8位加起来&#xff0c;进2位就OK。 本的办法&#xff0c;就是真的加起来&#xff0c;截前面10位。如我。 numList str.split() sum 0 for i in range(0,len(numList)):sum int(numList[i][0:50])print i,numList[i][…

.NET6之MiniAPI(十六):数据保护

对于web&#xff0c;安全是一个永久的话题&#xff0c;所以ASP.NET Core数据保护提供了一个简单&#xff0c;易用的加密API&#xff0c;可以用来保护数据&#xff0c;密钥管理和轮换。ASP.NET Core的数据保护是根据本机的一个key来生成加密码&#xff0c;然后再用这个key来解密…