位置: 编程技术 - 正文

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

  • 还有什么技术
  • 所得税汇算清缴调整项目
  • 周转材料低值易耗品的会计处理
  • 企业所得税季度申报时间
  • 增值税发票遗失怎么操作
  • 审计调整分录汇总的内容
  • 专票遗失后可以作废吗
  • 工程施工的借方和贷方
  • 自产的产品
  • 赠品的会计核算内容
  • 以前年度管理费用多计
  • 退休人员基本养老金调整幅度需要综合考虑什么因素
  • 双倍余额递减法考虑净残值吗
  • 境外保险是什么意思
  • 铲车费属于劳务费吗
  • 网络技术服务费 税率
  • 修理厂普通发票
  • 个税申报方式可以修改去年的吗
  • 审计报告的二维码扫出来是什么
  • 未分配50g
  • 转移性支出与转移性收入相对应主要包括
  • 虚开普票是不是很普遍
  • 保险公司赔偿的存货自然灾害损失
  • 公司股权转让流程是先工商还是税务
  • tplink无线网卡驱动802.11n
  • 增值税步骤
  • 前端向后端发送请求
  • 公司换基本户需要多久
  • php存储过程是什么
  • windows 11什么时候
  • 企业投资者撤回投资款
  • 企业公益性捐赠扣除比例
  • php常用设计模式(大总结)
  • 行政单位捐赠收入需要上缴财政吗
  • php做
  • 企业个人借款利息怎么做账
  • 日出的时候是圣诞节
  • yolov5 ios
  • 工会筹备金计税依据
  • phpstudy配置
  • 企业年度报告内容
  • javaweb项目开发流程
  • Node.js——http模块和导出共享
  • 认缴出资和注册资本
  • 预收账款发货
  • 电子发票的优点好处
  • 售后领料怎么做会计分录
  • 企业月末在产品数量变化不大时,最适宜
  • 年末财务报表是什么
  • 公司的个人所得税是什么意思
  • sqlserver2008不存在或拒绝访问怎么办
  • 普通发票和增值税发票的税率
  • 劳务报酬收入是否含税
  • sqlserver完整备份
  • 个人独资企业需要缴纳哪些税种
  • 预缴税款是什么税款
  • 对公可以转个人账户货款吗
  • 有限合伙企业的
  • 外购材料并提供建筑服务
  • 工程材料票占工程款的比例
  • 业务招待费进项票可以抵扣吗
  • 普票丢失可以用复印件入账吗
  • 个人独资企业要报税吗
  • xp系统控制面板在哪里打开
  • 电脑收藏夹文件恢复
  • linux 显示
  • warning bios upgrade
  • mac电脑怎么打开
  • 苹果Mac系统怎么切换输入法
  • win10升级 其他用户
  • linux删错文件
  • percona mongodb
  • npm yarn命令对比
  • delphi7教程
  • 个人出租商铺要交土地使用税吗
  • 天津怎么网上交电费
  • 税控盘怎么领用
  • 个税已申报税额为0是什么意思
  • 电子客票号码8768是什么
  • 当月专票作废流程
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设