位置: 编程技术 - 正文

mysql 显示SQL语句执行时间的代码(mysql显示数据库语句)

编辑:rootadmin

MySQL 的 SQL ?法?整主要都是使用 EXPLAIN , 但是????K?]?法知道??的 Ram(Memory)/CPU 等使用量.

於 MySQL 5.0. 以上?始支援 MySQL Query Profiler, 可以查?到此 SQL ??绦卸嗌?r?, ?K看出 CPU/Memory 使用量, ?绦羞^程中 System lock, Table lock 花多少?r?等等.

MySQL Query Profile ??介?可?: Using the New MySQL Query Profiler (.. ?表)

效能分析主要分下述三?(??自上篇):

Bottleneck analysis - focuses on answering the questions: What is my database server waiting on; what is a user connection waiting on; what is a piece of SQL code waiting on? Workload analysis - examines the server and who is logged on to determine the resource usage and activity of each. Ratio-based analysis - utilizes a number of rule-of-thumb ratios to gauge performance of a database, user connection, or piece of code. MySQL Query Profile 使用方法 ?? mysql> set profiling=1; # 此命令於 MySQL ?? information_schema 的 database 建立一?? PROFILING 的 table ?砑o?. SQL profiles show mysql> show profiles; # ???又?崴?姓Z法及使用?r?, 含???法都??o?. ex: (root@localhost) [test]> show profiles; # 注意 Query_ID, 下面?绦?r???等, 都是依 Query_ID 在??

+----------+------------+---------------------------+ | Query_ID | Duration | Query | +----------+------------+---------------------------+ | 1 | 0. | show profile for query 1 | | 2 | 0. | select * from users | | 3 | 0. | show tables | | 4 | 0. | mysql> show profiles | +----------+------------+---------------------------+ 查?所有花??r?加? mysql> select sum(duration) from information_schema.profiling where query_id=1; # Query ID = 1

+---------------+ | sum(duration) | +---------------+ | 0. | +---------------+ 查?各?绦须A段花?多少?r? mysql> show profile for query 1; # Query ID = 1

+--------------------+------------+ | Status | Duration | +--------------------+------------+ | (initialization) | 0. | | Opening tables | 0. | | System lock | 0. | | Table lock | 0. | | init | 0. | | optimizing | 0. | | statistics | 0. | | preparing | 0. | | executing | 0. | | Sending data | 0. | | end | 0. | | query end | 0. | | freeing items | 0. | | closing tables | 0. | | logging slow query | 0. | +--------------------+------------+ 查?各?绦须A段花?的各??源列表 mysql> show profile cpu for query 1; # Query ID = 1

+--------------------------------+----------+----------+------------+ | Status | Duration | CPU_user | CPU_system | +--------------------------------+----------+----------+------------+ | (initialization) | 0. | 0 | 0 | | checking query cache for query | 0. | 0 | 0 | | Opening tables | 0. | 0 | 0 | | System lock | 0. | 0 | 0 | | Table lock | 0. | 0. | 0 | | init | 0. | 0 | 0 | | optimizing | 0. | 0 | 0 | | statistics | 0. | 0 | 0 | | preparing | 0. | 0 | 0 | | executing | 0. | 0 | 0 | | Sending data | 0. | 0. | 0 | | end | 0. | 0 | 0 | | query end | 0. | 0 | 0 | | storing result in query cache | 0. | 0 | 0 | | freeing items | 0. | 0 | 0 | | closing tables | 0. | 0 | 0 | | logging slow query | 0. | 0 | 0 | +--------------------------------+----------+----------+------------+ mysql> show profile IPC for query 1;

+--------------------------------+----------+---------------+-------------------+ | Status | Duration | Messages_sent | Messages_received | +--------------------------------+----------+---------------+-------------------+ | (initialization) | 0. | 0 | 0 | | checking query cache for query | 0. | 0 | 0 | | Opening tables | 0. | 0 | 0 | | System lock | 0. | 0 | 0 | | Table lock | 0. | 0 | 0 | | init | 0. | 0 | 0 | | optimizing | 0. | 0 | 0 | | statistics | 0. | 0 | 0 | | preparing | 0. | 0 | 0 | | executing | 0. | 0 | 0 | | Sending data | 0. | 0 | 0 | | end | 0. | 0 | 0 | | query end | 0. | 0 | 0 | | storing result in query cache | 0. | 0 | 0 | | freeing items | 0. | 0 | 0 | | closing tables | 0. | 0 | 0 | | logging slow query | 0. | 0 | 0 | +--------------------------------+----------+---------------+-------------------+ 其它?傩粤斜 ALL - displays all information BLOCK IO - displays counts for block input and output operations CONTEXT SWITCHES - displays counts for voluntary and involuntary context switches IPC - displays counts for messages sent and received MEMORY - is not currently implemented PAGE FAULTS - displays counts for major and minor page faults SOURCE - displays the names of functions from the source code, together with the name and line number of the file in which the function occurs SWAPS - displays swap counts ?定 Profiling 存的 Size mysql> show variables where variable_name='profiling_history_size'; # ??是 ? ?? mysql> set profiling=0;

推荐整理分享mysql 显示SQL语句执行时间的代码(mysql显示数据库语句),希望有所帮助,仅作参考,欢迎阅读内容。

mysql 显示SQL语句执行时间的代码(mysql显示数据库语句)

文章相关热门搜索词:mysql显示字段,mysql显示所有数据,mysql查询结果显示,mysql中sql语句,mysql显示所有数据,mysql显示sql执行时间,mysql显示数据库语句,mysql显示数据库语句,内容如对您有帮助,希望把文章链接给更多的朋友!

mysql 设置查询缓存 可将如下语句query_cache_size=query_cache_type=1query_cache_limit=存放到/etc/my.cnf文件的[mysqld]下然后重启mysql数据库servicemysqldrestart就会启动mysql的缓存

MYSQL explain 执行计划 使用方法,在select语句前加上explain就可以了:如:explainselect*fromtest1EXPLAIN列的解释:table:显示这一行的数据是关于哪张表的type:这是重要的列,显示

MySQL 有输入输出参数的存储过程实例 1、实例DELIMITER//DROPPROCEDUREIFEXISTS`test`.`p_getvalue`//CREATEDEFINER=`root`@`localhost`PROCEDURE`p_getvalue`(inidvarchar(),outsvarchar())beginif(length(id)=)thenselect'A_B_C_D'intos;else

标签: mysql显示数据库语句

本文链接地址:https://www.jiuchutong.com/biancheng/312499.html 转载请保留说明!

上一篇:mysql 动态生成测试数据(mysql动态表单设计与实现)

下一篇:mysql 设置查询缓存(mysql设置查询超时时间)

  • 小微企业普惠性税收减免政策2019 13号
  • 车船使用税会打折么
  • 小微企业公司章程范本
  • 差旅费跨年报销说明
  • 已经开了发票需要退款怎么处理
  • 加班餐费有发票怎么入账
  • 服装公司的吊牌是什么
  • 租出非专利技术的摊销额会导致营业利润减少吗
  • 建筑 设计 招聘
  • 个体工商户增值税怎么计算
  • 主营业务收入包括哪些内容
  • 土地评估费计入什么会计科目
  • 什么是前期差错
  • 监督机关包括哪些
  • 企业购买理财产品收益会计分录
  • 外账成本要注意什么
  • 报关单毛重错了被海关查到
  • 股权转让的公允价值
  • 工会经费什么时候返还给企业
  • 自然人独资企业和一人有限责任公司
  • 过路费可以抵税吗
  • 补交前几年的进项发票
  • win10如何设置右键
  • 预付账款是企业销售过程中形成的一种非货币形式的债权
  • 进项票月初收到能抵上月
  • php编程代码
  • 缴纳公积金需要什么
  • 文件上传漏洞及解决方案
  • vue路由跳转原理
  • php ajax 教程
  • php正则函数内容匹配
  • 转让费交什么税
  • vue有哪些方法
  • ChatGPT的火爆出圈,你对它有几分了解?
  • 怎么才能学a1
  • 物业公司代收水费账务处理
  • 工程公司项目管理部管理制度
  • sqlyog
  • 什么科目需要结转到本年利润
  • 销售部门发生的商品维修费
  • 会计中金额的正负怎么算
  • 股权变更如何交税
  • 会计专业技术资格初级是什么职称
  • 企业工会经费的会计分录
  • 一般纳税人无票收入怎么做账分录呢
  • 加盟费收入如何入账
  • 工会经费如何支出
  • 总公司委托分公司开票及收款
  • 防伪系统制作
  • 季度末需要结转本年利润吗
  • 累计折旧的计提会计分录
  • 要约收购的条件和程序具体包括哪些?
  • 材料人工制造费用是什么成本
  • 税控盘和金税盘可以安装在一个电脑
  • 关闭terminal monitor
  • ubuntu16lts
  • 各种linux
  • 菜鸟flask
  • win8.0升级win8.1
  • linux怎么调整屏幕大小
  • 苹果mac使用
  • The file /boot/grub/stage1 not read cor 解决办法
  • win7双声道
  • 文件夹删不掉显示另一个程序打开
  • win7开机无法连接所有网络驱动器
  • 游戏新手引导架构
  • shell脚本入门详解
  • 队列remove
  • 用户体验ui
  • javascript html5 canvas实现可拖动省份的中国地图
  • vue的自定义组件
  • python多线程菜鸟教程
  • android面试2021
  • python中模块的作用
  • 江苏叉车证查询网上查询
  • 国家浙江税务局
  • 话费的发票可以做费用吗
  • 建筑企业异地预缴增值税计算
  • 安徽公务员流程各个阶段时间
  • 国家税务总局云平台网址
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设