位置: 编程技术 - 正文

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

  • 租赁合同管理台账范本
  • 百旺金赋的服务费必须交吗
  • 城镇土地使用税的征税范围有哪些
  • 贴息为什么要付利息呢
  • 专门借款资本化时点
  • 子公司给总公司开发票
  • 什么叫经纪代理服务
  • 旧设备变现损失抵减所得税怎么算
  • 海关完税价格表
  • 技术服务合同在北京由哪个法院管辖
  • 当月税负率怎么算
  • 收购公司收购款转给谁
  • 固定资产报废后怎么处理
  • 研发部门的办公费属于研发费的哪个类别
  • 固定资产清理会计处理例题
  • 租赁设备发票备注栏怎么填写
  • 一般纳税人附加税费减免政策
  • win11怎么用
  • 所得税到底按会计分录吗
  • koeids.dll
  • 怎么做年终结算工资
  • 出纳借方
  • 中拍网拍卖
  • 承包经营所得税税率表
  • 前端埋点sdk
  • php模板引擎执行时间
  • 累计摊销属于什么类科目
  • vue mocha
  • web自动化测试项目
  • 2023年美赛春季赛成绩查询
  • 库存盘亏进项税怎么抵扣
  • pgrep命令详解
  • 个体工商户和个人独资企业的区别
  • 未使用的固定资产计提折旧应当计入
  • 转让全部探明矿权合法吗
  • 小微企业所得税税率2.5% 10% 25%
  • 不计提工资直接发放可以吗
  • 房子是固定资产的好处
  • 帝国CMS根据不同会员组显示不同内容的方法
  • 哪些行业不用交税
  • 电子承兑对方拒绝签收多久能到账
  • 一般纳税人作废小规模时开的发票怎么报税
  • 一次性用品可以做什么东西
  • 基本户与一般户的区别与联系
  • 企业应付职工薪酬的会计核算
  • 工程造价咨询服务费收费标准
  • 应交税金及附加怎么计算
  • 员工的交通费发票可以报销嘛
  • 带有折扣的增值税专用发票图片
  • 去年的费用怎么做分录
  • 进项税认证未抵扣怎么做账
  • 会计记账凭证样本
  • 国库单一账户体系包括哪些账户
  • windows2008版本区别
  • 将IBM ServeRAID 8i卡的驱动整合到Win2003安装光盘里
  • debian系统
  • xp系统删除用户账户怎么没有删除键
  • win1020h2正式版下载
  • ubuntu20.0安装
  • mac怎么利用蓝牙传输文件
  • windows怎么更改网络状态
  • linux各种命令
  • 邮件传输过程中都使用哪些协议
  • win7运行窗口在哪
  • web前端开发应届生简历
  • label jsp
  • 异步加载场景
  • python3.8.3怎么用
  • 举例说明jquery的功能
  • 医院法制科工作职责
  • 开票软件重置密码去哪里
  • 虚假新闻造成的真实伤害
  • 江苏省国税电子发票查询
  • 什么情况适用简易诉讼程序
  • 国家税务总局内蒙古分局
  • 办图书馆怎么审批
  • 潍坊市的职工医保多少钱
  • 如何下载电子国税app
  • 个人所得税没申报会退吗
  • 德州市国土自然资源局
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设