位置: 编程技术 - 正文

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

  • 增值税应交税费科目
  • 回购股票为什么股价下跌
  • 公司给员工租的宿舍怎么交税
  • 现在开票还能用三方协议吗
  • 私人网银可以转到对公账户吗?
  • 塔吊基础属于哪一类
  • 调整账户和被调整账户的关系
  • 记账凭证按其适用的交易和事项分类可以分为
  • 企业所得税季度申报
  • 人力资源公司劳务派遣怎么收费
  • 红字发票需要做什么科目
  • 月底结转应交税费怎么弄
  • 专票红冲如何做账
  • 新个税法规定的专项扣除包括住房公积金
  • 资产负债表中其他流动资产怎么计算
  • 现代服务促销服务费的经营范围
  • 金融企业呆账准备金是否允许补提
  • 先收钱后开票怎么做分录
  • 支付装修押金会退吗
  • 融资性售后回租承租方为什么不交税
  • win10怎么关闭相机
  • 确认收入入账
  • 未办理装修手续
  • PHP:Memcached::get()的用法_Memcached类
  • 农产品收购发票使用范围
  • 建筑业预缴企业所得税是分季预缴按年抵减吗
  • 预算会计的核算范围
  • php处理图片需要什么扩展
  • php vld
  • 被雪覆盖的山峰
  • kafka图形化界面
  • php如何做app
  • 餐饮手撕票在哪里买多少钱
  • thinkphp 模块
  • php 遍历字符串
  • json_server
  • 软件企业享受增值服务
  • ChatGLM-6B:颠覆聊天AI的全新模型
  • tf club下载
  • 进项税加计抵减是什么意思
  • discuzcms
  • 大学生创新创业平台
  • 错账调整分录
  • 小微企业0税务报税流程
  • 中国移动发票抬头开错了可以重开吗
  • 一步一步的简单
  • mysql1290报错
  • 财务报表审计的基础是独立性和专业性
  • 出售无形资产净损益
  • 企业的所得税税率怎么计算
  • 低值易耗品的账务处理图片
  • mysqld-nt: Out of memory (Needed 1677720 bytes)解决方法
  • 城建税减半从什么时候开始
  • 建筑工程的税务处理
  • 地下车库的成本和房子哪个高
  • 企业现金购货限额
  • 主营业务成本为什么属于损益类科目
  • 服务行业收入会增加吗
  • 增值税发票丢失可以补开吗
  • 不动产分期抵扣表数据
  • 个人保险发票能做账吗
  • 什么叫社保差额调整
  • Win10预览版桌面图标和任务栏不翼而飞怎么办?
  • surfacepro3的笔
  • win7文件无法删除需要权限
  • win10d盘无法格式化,说另一个正在使用
  • batch批处理
  • 查看进程pid的命令是
  • shell脚本怎么写循环
  • javascript给表单赋值
  • jquery iframe写入内容
  • 欢迎使用微信支付
  • 重庆网上税务局个人怎么绑定企业账户
  • 税务新进公务员个人总结
  • 如何加强税务系统财务管理工作
  • 江苏国税申报
  • 学费减免政策
  • 专票最高几个点
  • 山东省级高新区什么级别
  • 内蒙古税务总局网站官网
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设