- 浏览: 2242533 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (423)
- FileNet相关 (3)
- 应用服务器相关 (22)
- Java综合 (77)
- 持久层 (24)
- struts (11)
- webservice (8)
- 虚拟机 (2)
- 光盘刻录 (0)
- AD及AD集群 (1)
- JS (33)
- F5 (0)
- loadrunner8.1 (0)
- Java 反编译工具 (2)
- DataBase (62)
- ant (1)
- 操作系统 (29)
- 我的任务 (3)
- 平台架构 (16)
- 业务规则引擎 (2)
- 模板 (1)
- EJB (5)
- spring (24)
- CMMI (1)
- 项目管理 (20)
- LDAP (13)
- JMS (10)
- JSP (19)
- JBPM (2)
- web MVC框架设计思想 (2)
- 第三方支付平台 (2)
- BUG管理工具 (1)
- 垃圾站 (2)
- php (1)
- swing (1)
- 书籍 (1)
- QQ qq (2)
- 移动互联网 (26)
- 爱听的歌曲 (0)
- hadoop (4)
- 数据库 (9)
- 设计模式 (1)
- 面试经验只谈 (1)
- 大数据 (9)
- sp (1)
- 缓存数据库 (8)
- storm (2)
- taobao (2)
- 分布式,高并发,大型互联网,负载均衡 (6)
- Apache Ignite (0)
- Docker & K8S (0)
最新评论
-
wangyudong:
新版本 Wisdom RESTClienthttps://gi ...
spring rest mvc使用RestTemplate调用 -
wangyudong:
很多API doc生成工具生成API文档需要引入第三方依赖,重 ...
spring rest mvc使用RestTemplate调用 -
zhaoshijie:
cfying 写道大侠,还是加载了两次,怎么解决啊?求。QQ: ...
spring容器加载完毕做一件事情(利用ContextRefreshedEvent事件) -
xinglianxlxl:
对我有用,非常感谢
spring容器加载完毕做一件事情(利用ContextRefreshedEvent事件) -
k_caesar:
多谢,学习了
利用maven的resources、filter和profile实现不同环境使用不同配置文件
关键字:性能优化重要的mysql profile功能
mysql的sql语句优化都使用explain,但是这个没有办法知道详细的Memory/CPU等使用量
MySQL Query Profiler, 可以查询到此 SQL 语句会执行多少, 并看出 CPU/Memory 使用
量, 执行过程 System lock, Table lock 花多少时间等等.
mysql> show variables like 'profiling%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| profiling | OFF |
| profiling_history_size | 15 |
+------------------------+-------+
开启此功能
mysql>set profiling=1;
mysql> show variables like 'profiling%';
# 此命令会让mysql在 information_schema 的 database 建立一個 PROFILING 的
table 来记录.
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| profiling | ON |
| profiling_history_size | 15 |
+------------------------+-------+
profiling_history_size记录多少次查询
mysql> show profiles;
+----------+------------+------------------------------------+
| Query_ID | Duration | Query |
+----------+------------+------------------------------------+
| 1 | 0.00018100 | show variables like 'profiling%' |
| 2 | 0.00020400 | show variables like 'profiling%' |
| 3 | 0.00007800 | set profiling=1 |
| 4 | 0.00011000 | show variables like 'profiling%' |
| 5 | 0.00002400 | select count(1) from `mrhao_stats` |
| 6 | 1.52181400 | select count(*) from `mrhao_stats` |
| 7 | 0.00026900 | show variables like 'profiling%' |
mysql> show profile for query 6;
+--------------------------------+----------+
| Status | Duration |
+--------------------------------+----------+
| (initialization) | 0.000003 |
| checking query cache for query | 0.000042 |
| Opening tables | 0.00001 |
| System lock | 0.000004 |
| Table lock | 0.000025 |
| init | 0.000009 |
| optimizing | 0.000003 |
| statistics | 0.000007 |
| preparing | 0.000007 |
| executing | 0.000004 |
| Sending data | 1.521676 |
| end | 0.000007 |
| query end | 0.000003 |
| storing result in query cache | 0.000002 |
| freeing items | 0.000006 |
| closing tables | 0.000004 |
| logging slow query | 0.000002 |
+--------------------------------+----------+
17 rows in set (0.00 sec)
mysql> show profile cpu for query 6;
+--------------------------------+----------+----------+------------+
| Status | Duration | CPU_user | CPU_system |
+--------------------------------+----------+----------+------------+
| (initialization) | 0.000003 | 0 | 0 |
| checking query cache for query | 0.000042 | 0.001 | 0 |
| Opening tables | 0.00001 | 0 | 0 |
| System lock | 0.000004 | 0 | 0 |
| Table lock | 0.000025 | 0 | 0 |
| init | 0.000009 | 0 | 0 |
| optimizing | 0.000003 | 0 | 0 |
| statistics | 0.000007 | 0 | 0 |
| preparing | 0.000007 | 0 | 0 |
| executing | 0.000004 | 0 | 0 |
| Sending data | 1.521676 | 1.631752 | 0.036995 |
| end | 0.000007 | 0 | 0 |
| query end | 0.000003 | 0 | 0 |
| storing result in query cache | 0.000002 | 0 | 0 |
| freeing items | 0.000006 | 0 | 0 |
| closing tables | 0.000004 | 0 | 0 |
| logging slow query | 0.000002 | 0 | 0 |
+--------------------------------+----------+----------+------------+
17 rows in set (0.00 sec)
* 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
查询时间跟cpu的使用
mysql> select min(seq) seq,state,count(*) numb_ops,
round(sum(duration),5) sum_dur, round(avg(duration),5) avg_dur,
round(sum(cpu_user),5) sum_cpu, round(avg(cpu_user),5) avg_cpu
from information_schema.profiling
where query_id = 7
group by state
order by seq;
关闭此功能
mysql> set profiling=0;
mysql> show variables like 'profiling%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| profiling | OFF |
| profiling_history_size | 15 |
+------------------------+-------+
发表评论
-
mysql源码解读之事务提交过程--第二篇
2018-01-10 15:03 463关键字:mysql源码解读 ... -
循环创建多张表 和 多个数据库sql语句(数据库水平分库分表时方便)
2016-03-04 12:58 12320关键字:循环创建多张 ... -
高可用、开源的Redis缓存集群方案
2015-04-16 12:25 3713推荐综合架构交流群:J ... -
Oracle实现类split函数的方
2015-04-16 10:10 599关键字:Oracle实现类split函数的方 项目里需要保存结 ... -
各种Nosql数据库系统对比及应用场景分析
2015-04-15 16:29 720关键字:各种Nosql数据库系统对比及应用场景分析 导读:Kr ... -
数据库迁移之从oracle 到 MySQL
2015-04-11 09:38 866关键字:数据库迁移之从oracle 到 MySQL 开场白: ... -
Mongodb命令大全
2015-03-18 11:18 760关键字:Mongodb命令大全 他支持的数据结构非常松散,是类 ... -
MongoDB中缩减Shard集群(删除一个Shard)--删除一个分片
2015-03-13 12:29 3572关键字:MongoDB中缩减Shard集群(删除一个Shard ... -
Mongodb副本集(三个节点:一主一从一仲裁)-配置文件方式启动
2015-03-05 17:32 2019关键字:Mongodb副本集(三个节点:一主一从一仲裁)-配置 ... -
win7 64位的数据源(ODBC)配置问题
2015-01-20 16:36 1028关键字:win7 64位的数据源(ODBC)配置问题 ... -
atomikos(com.atomikos.icatch.SysException: Error in init(): Log already in use)
2014-10-15 13:12 8444关键字:atomikos(com.atomikos.icatc ... -
Mysql高可用架构
2014-09-02 11:41 2762关键字:Mysql高可用架构 最近花了点时间研究了一下mys ... -
MySQL原生HA方案 – Fabric体验之旅
2014-08-21 13:13 7052关键字:MySQL原生HA方案 – Fabric体验之旅 ta ... -
性能优化重要的mysql profile功能
2014-02-10 15:25 51关键字:性能优化重要的mysql profile功能 my ... -
mysql profile功能
2014-02-10 15:12 24关键字:mysql profile功能 mysql的sql ... -
mybatis优化
2013-11-29 00:12 6403关键字:mybatis优化 1、每个bean都要有对应的g ... -
动态分库分表策略
2013-11-21 15:52 1319关键字:动态分库分表策略 参考网址:http://drag ... -
Windows 2008下如何配置Oracle ASM
2013-08-19 13:23 58756关键字:Windows 2008下如何配置Oracle ASM ... -
plsql 链接远程机器零配置
2013-07-17 12:06 3844关键字:plsql 链接远程机器零配置 打开plsql会弹 ... -
MySQL+ODBC+5.1.9-win32驱动.rar
2012-11-16 13:51 1035关键字:MySQL+ODBC+5.1.9-win32驱动.r ...
相关推荐
分析SQL执行带来的开销是优化SQL的重要手段。在MySQL数据库中,可以通过配置profiling参数来启用SQL剖析。该参数可以在全局和session级别来设置。对于全局级别则作用于整个MySQL实例,而session级别紧影响当前...
主要介绍了MySQL中使用show profile命令分析性能的用法整理,show profiles是数据库性能优化的常用命令,需要的朋友可以参考下
51.MySQL高级_用Show Profile进行sql分析.avi 50.MySQL高级_批量插入数据脚本.avi 49.MySQL高级_慢查询日志.avi 48.MySQL高级_为排序使用索引OrderBy优化.avi 47.MySQL高级_in和exists.avi 46.MySQL高级_...
这个是MySQL5.5再contos6下的安装方法 MySQL 是...索引的优化策略,了解innodb和myisam存储引擎,熟悉MySQL锁机制,能熟练配置MySQL主从复制,熟练掌握explain、show profile、慢查询日志等日常SQL诊断和性能分析策略。
尚硅谷_MySQL高级_用Show Profile进行sql分析 · 52.尚硅谷_MySQL高级_全局查询日志 · 53.尚硅谷_MySQL高级_数据库锁理论概述 · 54.尚硅谷_MySQL高级_读锁案例讲解 · 55.尚硅谷_MySQL高级_读锁案例讲解2 · ...
MySQL是目前流行的关系型数据库管理系统,在WEB...索引的优化策略,了解innodb和myisam存储引擎,熟悉MySQL锁机制,能熟练配置MySQL主从复制,熟练掌握explain、show profile、慢查询日志等日常SQL诊断和性能分析策略。
MySQL是目前流行的关系型数据库管理系统,在WEB...索引的优化策略,了解innodb和myisam存储引擎,熟悉MySQL锁机制,能熟练配置MySQL主从复制,熟练掌握explain、show profile、慢查询日志等日常SQL诊断和性能分析策略。
最近遇到一个查询比较慢的sql语句,用了子查询,大概需要0.8秒左右,这个消耗时间比较长,严重影响了性能,所以需要进行优化。单独查询单表或者子查询记录都很快,下面来看看详细的介绍。 开启profile mysql> show...
外连接查询,自连接查询,联合查询union,unionall,子查询,事务,四大特性ACID,并发事务,进阶篇,存储引擎,InnoDB,MyISAM,Memory,存储引擎特点,存储引擎的选择,性能分析,查看执行频次,慢查询日志,profile,explain,索引,...
本教程为授权出品 MySQL是目前流行的关系型...索引的优化策略,了解innodb和myisam存储引擎,熟悉MySQL锁机制,能熟练配置MySQL主从复制,熟练掌握explain、show profile、慢查询日志等日常SQL诊断和性能分析策略。
1. show variables like ‘%profiling%’;(查看profiling信息) ...4. show profile for query 4; show profile 的格式如下: SHOW PROFILE [type [, type] … ] [FOR QUERY n] [LIMIT row_
用于MYSQL数据库关键SQL语句的资源消耗的量化以及针对性地分析和优化
This book will get you started with the latest benchmarking, profiling and monitoring tools for PHP, MySQL and JavaScript using Docker-based technologies. From optimizing ...
背景前段时间在做应用的性能优化时,分析了下整体请求,profile看到90%的时间更多的是一些外部服务的I/O等待,cpu利用率其实不高,在10%以 下。 单次请求的响应时间在50ms左右,所以tps也不会太高,测试环境压力...
数组、链表、二叉树、队列、栈的各种操作(性能,场景) 二分查找和各种变种的二分查找 各类排序算法以及复杂度分析(快排、归并、堆) 各类算法题(手写) 理解并可以分析时间和空间复杂度。 动态规划(笔试回回有...
SQL Server 2005的30个最重要特点 同时安装sql2000和sql2005的经验 类如何与界面绑定 在Asp.net中如何用SQLDMO来获取SQL Server中的对象信息 使用Relations建立表之间的关系并却使用PagedDataSource类对DataList进行...