怎样创建fpga是什么

查看: 1041|回复: 3
show profile for query 2 有什么实际意义
论坛徽章:0
认证徽章论坛徽章:27
本帖最后由 mchdba 于
21:21 编辑
可以看第二个查询语句的详细执行过程,使用profile可以详细的看到执行这个sql语句锁需要的内存、cpu、io等,而且还可以看到每一步所消耗掉的时间,只是sending data这一选项有些诡异,因为这里面不仅仅包括了网络的传输而且还包括了读磁盘文件到内存缓存的时间。
有的时候你无法从这里分析是读取磁盘文件慢呢还是网络慢呢,这个时候就只有找别的途径先看看磁盘以及网络情况来判断了。
论坛徽章:281
查看启用profiling后执行的第二条语句的相关信息~~
论坛徽章:30
楼主的意思大概是这个东西不能事实抓取正在运行的其它连接的查询信息吧?什么能像SQL Server的Profiler一样就好了。
itpub.net All Right Reserved. 北京皓辰网域网络信息技术有限公司版权所有    
 北京市公安局海淀分局网监中心备案编号: 广播电视节目制作经营许可证:编号(京)字第1149号温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
阅读(3018)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_087075',
blogTitle:'mysql的show profile',
blogAbstract:'这里还需要注意一点就是,需要安装profile模块才能实现。
如下内容转自:'
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}MySQL SHOW PROFILE(剖析报告)的查看_数据库技术_Linux公社-Linux系统门户网站
你好,游客
MySQL SHOW PROFILE(剖析报告)的查看
来源:Linux社区&
作者:wzq609
前言:SHOW PROFIL命令是MySQL提供可以用来分析当前会话中语句执行的资源消耗情况。可以用于SQL的调优的测量。
一、参数的开启和关闭设置
1.1& 参数的查看
默认情况下,参数处于关闭状态,并保存最近15次的运行结果
mysql&& show variables like 'profiling%';
+------------------------+-------+
| Variable_name& & & & & | Value |
+------------------------+-------+
| profiling& & & & & & & | OFF&
| profiling_history_size | 15& & |
+------------------------+-------+
2 rows in set&
1.2 参数的开启和关闭(参数为会话级参数,只对当前会话有效)
开启操作如下:
mysql& SET profiling=1;或 SET profiling=
mysql&& SET profiling=
Query OK, 0 rows affected
mysql&& show variables like 'profiling%';
+------------------------+-------+
| Variable_name& & & & & | Value |
+------------------------+-------+
| profiling& & & & & & & | ON& & |
| profiling_history_size | 15& & |
+------------------------+-------+
2 rows in set
关闭的操作: mysql& SET profiling=0;或 SET profiling=
二、操作步骤
2.1 进行开启操作: SET profiling=
2.2 运行相应的SQL语句;
2.3 查看总体结果:
2.4 查看详细的结果:SHOW PROFILE FOR QUERY n,这里的n就是对应SHOW PROFILES输出中的Query_ID;
+----------+------------+------------------------------------+
| Query_ID | Duration&
| Query& & & & & & & & & & & & & & & |
+----------+------------+------------------------------------+
|& & & & 1 | 0. | select count(*) from tab_user_info |
|& & & & 2 |& 0.0013575 | select count(*) from tab_tel_area& |
|& & & & 3 |& &
9.7E-5 | select count(*) from tab_tel_area& |
|& & & & 4 |&
0.005193 | show variables like 'profiling%'&
+----------+------------+------------------------------------+
4 rows in set
mysql& show profile for query 2;
+--------------------------------+----------+
| Status& & & & & & & & & & & &
| Duration |
+--------------------------------+----------+
| starting& & & & & & & & & & &
| checking query cache for query | 4.7E-5&
| Opening tables& & & & & & & &
| 0.001163 |
| System lock& & & & & & & & & & | 4E-6& &
| Table lock& & & & & & & & & &
| init& & & & & & & & & & & & &
| optimizing& & & & & & & & & &
| executing& & & & & & & & & & & | 1.4E-5&
| end& & & & & & & & & & & & & & | 5E-6& &
| query end& & & & & & & & & & & | 3E-6& &
| freeing items& & & & & & & & & | 3.1E-5&
| storing result in query cache& | 5E-6& &
| logging slow query& & & & & &
| cleaning up& & & & & & & & & & | 2E-6& &
+--------------------------------+----------+
14 rows in set
说明:报告给出了查询执行的每个步骤及花费的时间,当语句是很简单的一次执行的时候,可以很清楚的看出语句每个顺序花费的时间,但是当语句是嵌套循环等操作的时候,看这个报告就会变得很痛苦,因此整理了以下语句对相同类型的操作进行汇总,脚本如下:
mysql& SET @QUERY_ID=1;
mysql& SELECT STATE,SUM(DURATION) AS TOTAL_R,
ROUND(100*SUM(DURATION)/(SELECT SUM(DURATION)
FROM INFORMATION_SCHEMA.PROFILING
WHERE QUERY_ID=@QUERY_ID),2) AS PCT_R,
COUNT(*) AS CALLS,
SUM(DURATION)/COUNT(*) AS "R/CALL"
FROM INFORMATION_SCHEMA.PROFILING
WHERE QUERY_ID=@QUERY_ID
GROUP BY STATE
ORDER BY TOTAL_R DESC;
总结:这个工具又让我联想到了的autotrace工具,如果有相应的执行计划一起带出来,那么对语句的调优帮助将更大;
--------------------------------------分割线 --------------------------------------
14.04下安装MySQL
《MySQL权威指南(原书第2版)》清晰中文扫描版 PDF
Ubuntu 14.04 LTS 安装 LNMP Nginx\PHP5 (PHP-FPM)\MySQL
Ubuntu 14.04下搭建MySQL主从服务器
Ubuntu 12.04 LTS 构建高可用分布式 MySQL 集群
Ubuntu 12.04下源代码安装MySQL5.6以及Python-MySQLdb
MySQL-5.5.38通用二进制安装
--------------------------------------分割线 --------------------------------------
本文永久更新链接地址:
相关资讯 & & &
   同意评论声明
   发表
尊重网上道德,遵守中华人民共和国的各项有关法律法规
承担一切因您的行为而直接或间接导致的民事或刑事法律责任
本站管理人员有权保留或删除其管辖留言中的任意内容
本站有权在网站内转载或引用您的评论
参与本评论即表明您已经阅读并接受上述条款MySQL中使用SHOW PROFILE命令分析性能的用法整理,MySQL教程,MySQL案例,MySQL实例
本站中文域名:、 
        
     
 |  |  |  |  
     |     |     |   
您的位置: &&
&& MySQL中使用SHOW PROFILE命令分析性能的用法整理
MySQL中使用SHOW PROFILE命令分析性能的用法整理
show profile是由JereCole捐献给MySQL社区版本的&。默认的是关闭的,但是会话级别可以开启这个功能&。开启它可以让MySQL收集在执行语句的时候所使用的资源&。为了统计报表,把profiling设为1
mysql& SET profiling = 1;
之后在运行一个查询
mysql& SELECT COUNT(DISTINCT actor.first_name) AS cnt_name, COUNT(*) AS cnt
-& FROM sakila.film_actor
-& INNER JOIN sakila.actor USING(actor_id)
-& GROUP BY sakila.film_actor.film_id
-& ORDER BY cnt_name DESC;
997 rows in set (0.03 sec)
这个执行语句的剖析信息存储在这个会话中&。使用SHOW PROFILES进行查看&。
mysql& SHOW PROFILES\G
*************************** 1. row ***************************
Query_ID: 1
Duration: 0.
Query: SELECT COUNT(DISTINCT actor.first_name) AS cnt_name,...
你可以使用SHOW PROFILE语句来获取已经存储的剖析数据&。如果不加参数,会显示状态以及它们持续的时间&。
mysql& SHOW PROFILE;
+------------------------+-----------+
| Status | Duration |
+------------------------+-----------+
| (initialization) | 0.000005 |
| Opening tables | 0.000033 |
| System lock | 0.000037 |
| Table lock | 0.000024 |
| init | 0.000079 |
| optimizing | 0.000024 |
| statistics | 0.000079 |
| preparing | 0.00003 |
| Creating tmp table | 0.000124 |
| executing | 0.000008 |
| Copying to tmp table | 0.010048 |
| Creating sort index | 0.004769 |
| Copying to group table | 0.0084880 |
| Sorting result | 0.001136 |
| Sending data | 0.000925 |
| end | 0.00001 |
| removing tmp table | 0.00004 |
| end | 0.000005 |
| removing tmp table | 0.00001 |
| end | 0.000011 |
| query end | 0.00001 |
| freeing items | 0.000025 |
| removing tmp table | 0.00001 |
| freeing items | 0.000016 |
| closing tables | 0.000017 |
| logging slow query | 0.000006 |
+------------------------+-----------+
每行都是状态变化的过程以及它们持续的时间&。Status那一列和SHOW FULL PROCESSLIST的State应该是一致的&。
这个值是来自于thd-&proc_info变量&。因此你所查看的这个值是直接来自MySQL内部的&。尽管这些数值是比较直接易懂的,你也可以查看MySQL手册&。
你可以给SHOW PROFILES指定一个Query_ID来查看指定的语句,还可以给输出添加新的列&。如,查看用户和CPU使用&。可以用如下命令&。
mysql& SHOW PROFILE CPU FOR QUERY 1;
SHOW PROFILE可以深入的查看服务器执行语句的工作情况&。以及也能帮助你理解执行语句消耗时间的情况&。一些限制是它没有实现的功能,不能查看和剖析其他连接的语句,以及剖析时所引起的消耗&。
SHOW PROFILES显示最近发给服务器的多条语句,条数根据会话变量profiling_history_size定义,默认是15,最大值为100&。设为0等价于关闭分析功能&。
SHOW PROFILE FOR QUERY n,这里的n就是对应SHOW PROFILES输出中的Query_ID&。
+----------+-------------+---------------------------------------+
| Query_ID | Duration | Query
+----------+-------------+---------------------------------------+
| 1 | 0. | alter table table1 drop column c3 int |
| 2 | 70. | alter table table1 drop column c3 |
| 3 | 0. | show tables
| 4 | 0. | select * from table1 where id=2 |
| 5 | 0. | select count(1) from tables1
| 6 | 0. | select count(1) from table1
| 7 | 0. | alter table tables1 drop c1
| 8 | 0. | alter table table1 drop c1
+----------+-------------+---------------------------------------+
8 rows in set (0.00 sec)
mysql& SHOW PROFILE FOR QUERY 2; #查看alter table table1 drop column c3的分析
+------------------------------+-----------+
| Duration |
+------------------------------+-----------+
| starting
| 0.000183 |
| checking permissions
| 0.000057 |
| checking permissions
| 0.000059 |
| 0.000060 |
| Opening tables
| 0.000071 |
| System lock
| 0.000062 |
| 0.000080 |
| creating table
| 0.005052 |
| After create
| 0.000220 |
| copy to tmp table
| 0.000244 |
| rename result table
| 70.364027 |
| 0.000575 |
| Waiting for query cache lock | 0.000062 |
| 0.000075 |
| query end
| 0.000057 |
| closing tables
| 0.000061 |
| freeing items
| 0.000080 |
| logging slow query
| 0.000056 |
| logging slow query
| 0.000098 |
| cleaning up
| 0.000059 |
+------------------------------+-----------+
20 rows in set (0.00 sec)
如果没有指定FOR QUERY,那么输出最近一条语句的信息&。
LIMIT部分的用法与SELECT中LIMIT子句一致,不赘述&。
type是可选的,取值范围可以如下:
ALL 显示所有性能信息
BLOCK IO 显示块IO操作的次数
CONTEXT SWITCHES 显示上下文切换次数,不管是主动还是被动
CPU 显示用户CPU时间、系统CPU时间
IPC 显示发送和接收的消息数量
MEMORY [暂未实现]
PAGE FAULTS 显示页错误数量
SOURCE 显示源码中的函数名称与位置
SWAPS 显示SWAP的次数
mysql& show profile cpu for query 2;
+------------------------------+-----------+----------+------------+
| Duration | CPU_user | CPU_system |
+------------------------------+-----------+----------+------------+
| starting
| 0.000183 | 0.000000 | 0.000000 |
| checking permissions
| 0.000057 | 0.000000 | 0.000000 |
| checking permissions
| 0.000059 | 0.000000 | 0.000000 |
| 0.000060 | 0.000000 | 0.000000 |
| Opening tables
| 0.000071 | 0.000000 | 0.000000 |
| System lock
| 0.000062 | 0.000000 | 0.000000 |
| 0.000080 | 0.000000 | 0.001000 |
| creating table
| 0.005052 | 0.003000 | 0.001000 |
| After create
| 0.000220 | 0.000000 | 0.000000 |
| copy to tmp table
| 0.000244 | 0.000000 | 0.000000 |
| rename result table
| 70.364027 | 7.470864 | 41.612674 |
| 0.000575 | 0.000000 | 0.001000 |
| Waiting for query cache lock | 0.000062 | 0.000000 | 0.000000 |
| 0.000075 | 0.000000 | 0.000000 |
| query end
| 0.000057 | 0.000000 | 0.000000 |
| closing tables
| 0.000061 | 0.000000 | 0.000000 |
| freeing items
| 0.000080 | 0.000000 | 0.000000 |
| logging slow query
| 0.000056 | 0.000000 | 0.000000 |
| logging slow query
| 0.000098 | 0.000000 | 0.000000 |
| cleaning up
| 0.000059 | 0.000000 | 0.000000 |
+------------------------------+-----------+----------+------------+
20 rows in set (0.00 sec)
SHOW PROFILE ALL FOR QUERY 2;的信息还可以通过SELECT * FROM information_schema.profiling WHERE query_id = 2 ORDER BY获取&。
这个命令只是在本会话内起作用,即无法分析本会话外的语句&。
开启分析功能后,所有本会话中的语句都被分析(甚至包括执行错误的语句),除了SHOW PROFILE和SHOW PROFILES两句本身&。
应用示例:使用SHOW PROFILE分析查询缓存命中的性能优势&。
mysql& set profiling=1;
Query OK, 0 rows affected (0.00 sec)
mysql& select count(1) as cnt from tran_
1 row in set (0.00 sec)
由于已经启用了查询缓存,相同查询(非分区表)可以直接在查询缓存中命中&。
mysql& select count(1) as cnt from tran_
我们仔细看下两个同样的语句的分析&。
mysql& show profile source for query 1;
+--------------------------------+----------+-----------------------+---------------+-------------+
| Duration | Source_function | Source_file | Source_line |
+--------------------------------+----------+-----------------------+---------------+-------------+
| starting
| 0.000048 | NULL
| Waiting for query cache lock | 0.000013 | try_lock
| sql_cache.cc |
| checking query cache for query | 0.000040 | send_result_to_client | sql_cache.cc | 1561 |
| checking permissions
| 0.000023 | check_access
| sql_parse.cc | 4751 |
| Opening tables
| 0.000040 | open_tables
| sql_base.cc | 4831 |
| System lock
| 0.000020 | mysql_lock_tables | lock.cc |
| Waiting for query cache lock | 0.000037 | try_lock
| sql_cache.cc |
| 0.000020 | mysql_select
| sql_select.cc | 2579 |
| optimizing
| 0.000015 | optimize
| sql_select.cc |
| statistics
| 0.000017 | optimize
| sql_select.cc | 1056 |
| preparing
| 0.000016 | optimize
| sql_select.cc | 1078 |
| executing
| 0.000015 | exec
| sql_select.cc | 1836 |
| Sending data
| 0.003875 | exec
| sql_select.cc | 2380 |
| 0.000018 | mysql_select
| sql_select.cc | 2615 |
| query end
| 0.000015 | mysql_execute_command | sql_parse.cc | 4440 |
| closing tables
| 0.000016 | mysql_execute_command | sql_parse.cc | 4492 |
| freeing items
| 0.000016 | mysql_parse
| sql_parse.cc | 5640 |
| Waiting for query cache lock | 0.000012 | try_lock
| sql_cache.cc |
| freeing items
| 0.000032 | NULL
| Waiting for query cache lock | 0.000017 | try_lock
| sql_cache.cc |
| freeing items
| 0.000016 | NULL
| storing result in query cache | 0.000017 | end_of_result
| sql_cache.cc | 1020 |
| logging slow query
| 0.000018 | log_slow_statement | sql_parse.cc | 1461 |
| logging slow query
| 0.000050 | log_slow_statement | sql_parse.cc | 1470 |
| cleaning up
| 0.000018 | dispatch_command | sql_parse.cc | 1417 |
+--------------------------------+----------+-----------------------+---------------+-------------+
25 rows in set (0.00 sec)
mysql& show profile source for query 2;
+--------------------------------+----------+-----------------------+--------------+-------------+
| Duration | Source_function | Source_file | Source_line |
+--------------------------------+----------+-----------------------+--------------+-------------+
| starting
| 0.000051 | NULL
| Waiting for query cache lock | 0.000014 | try_lock
| sql_cache.cc |
| checking query cache for query | 0.000016 | send_result_to_client | sql_cache.cc | 1561 |
| checking privileges on cached | 0.000013 | send_result_to_client | sql_cache.cc | 1652 |
| checking permissions
| 0.000015 | check_access
| sql_parse.cc | 4751 |
| sending cached result to clien | 0.000036 | send_result_to_client | sql_cache.cc | 1749 |
| logging slow query
| 0.000017 | log_slow_statement | sql_parse.cc | 1461 |
| cleaning up
| 0.000018 | dispatch_command | sql_parse.cc | 1417 |
+--------------------------------+----------+-----------------------+--------------+-------------+
8 rows in set (0.00 sec)
可以清晰地看到缓存中命中时,大大节省了后台的开销&。当然缓存的使用也需要根据各种场景(表的数据规模,更新频率等)考察使用,并不是启用缓存就一定能够提高查询效率&。这里仅仅作为SHOW PROFILE的一个应用示例&。
Google搜索中
搜狗搜索中
在线教程导航
数据库开发
车友晒价详情
<font color="#FF
太仓汽车4S店 赠 踏板 脚垫 旅行架 倒车雷达 坐垫价格214900
苏州华成 赠 踏板 脚垫 旅行架 倒车雷达 坐垫 价格213000
<font color="#FF万
江都的4S店
<font color="#FF万
还没去4s店,价格网上的。
当时电话谈的是25.8万,但是这个价格包括了我的0.6万元的公务员补贴(厂方给的)以及要求做1万元装潢,
如果不做装潢也不是公务员身份,应该就是27万裸车了。
贷款利息免,不过有手续费3000
<font color="#FF
优惠16500,自己加5000装潢请您填写优惠幅度以及购车地点等详情。
<font color="#FF万
南京卡子门三千元优惠
<font color="#FF万
南京协众,没什么具体谈,只说购买时给点优惠
<font color="#FF万
镇江东南三菱9.28W新款V5plus,我一次性买两台一台1.5,一台1.5T
团购车型:
加入微信号,了解汽车///活动
| 站长工具:
热门搜索:
| 热门网游:         
加入官方微信号
渠道报价/招聘
任你发任你查
All Rights Reserved.
南京网爵数码科技有限责任公司版权所有
 |  | }

我要回帖

更多关于 fpga 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信