位置: 编程技术 - 正文

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设置查询超时时间)

  • 增值税金税盘开票的结论
  • 支付的画图费没有发票要如何处理
  • 金融资产的构成
  • 养老院营利性与非营利如何认定
  • 救援车拉货交警查吗?
  • 贷款利息不能抵扣进项税
  • 一般纳税人开差额票的税率
  • 技术转让收入纳税调整
  • 提前给货款计入什么科目
  • 取得无形资产当期收入
  • 报销增值税专票绿的
  • 12月份未计提的费用汇算清缴如何调整?
  • 母公司借款给子公司作为投资
  • 增值税专用发票抵扣期限
  • 房地产营改增后开票
  • 加速折旧税收优惠
  • 个人转账收入要缴税吗
  • 物业代收水电费,业主不交怎么办
  • 应付利息在资产负债表中属于什么项目
  • 能抵扣税款的发票有哪些
  • 支付工人保险费计入什么科目里
  • 个人所得汇算清缴是什么
  • 设备安装服务费税收分类编码
  • 电脑自动更新系统怎么关闭
  • 关于销售免税品的规定
  • 王者荣耀中马可波罗的一技能和大招
  • 物业公司给业主的生日祝福
  • mac环境搭建
  • 返还保证金的法律依据
  • ekb install
  • 社保征集单是什么样子的
  • nuxt怎么用
  • 抵免法的缺点主要有以下几点
  • 二连浩特老照片
  • 工程未审计资金能支付到多少
  • ssm算前后端分离吗
  • 巴芬岛旅游
  • 完成认证后开具什么证明
  • vue-plugin-hiprint vue hiprint vue使用hiprint打印控件VUE HiPrint HiPrint简单使用
  • 前端基础
  • 我初次尝试制作的英文怎么写
  • php单例模式懒汉和饿汉
  • 自产自销的农产品可以抵税吗
  • 一般人转小规模政策到什么时候
  • 固定资产售后回购会计处理
  • 出售固定资产如何申报企业所得税
  • 股东分红后股票会涨吗
  • day35-JSON&Ajax03
  • mysql常见操作
  • 母公司给子公司借款要利息吗
  • 一般纳税人简易征收最新政策
  • Excel导入数据库出错
  • 小规模纳税人企业所得税2023
  • 典当行借款合同需交印花税吗
  • 政府对企业提交的项目申请报告主要从等方面进行核准
  • 没有收据不开发票
  • 固定资产被盗报警
  • 未使用的机器设备有没有实体性贬值
  • 城投公司是什么东西
  • 股东实收资本超额到位
  • mysql安装配置教程5.7.25
  • qq windows
  • ktpcntr.exe
  • win7用户账户控制设置电脑重启后恢复
  • linux禁止ping的命令
  • win7系统怎么设置屏保
  • WIN10系统摄像头在哪打开
  • linux系统如何禁用光驱
  • 批处理文件是脚本吗
  • js用什么编写
  • nodejs获取客户端设备信息
  • linux系统监控脚本
  • jquery mobile ui
  • jquery点击事件写法
  • 从零开始学什么
  • Unity3D游戏开发引擎
  • jQuery版AJAX简易封装代码
  • 使用SQLite本地数据库
  • 河北税务局是干嘛的
  • 如何证明发货前货物完好
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设