本篇文章给人人带来的内容是关于Mysql运用profile理会sql开支的代码,有肯定的参考价值,有须要的朋侪能够参考一下,愿望对你有所协助。
Mysql运用profile理会sql开支
1.运用之前先检察当前数据库的版本信息,低版本没法运用. show version(); 或许 show variables like '%version%' 2.检察profiling show variables like '%profil%' ; result: +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | have_profiling | YES | --只读变量,用于掌握是不是由体系变量开启或禁用profiling | profiling | OFF | --开启SQL语句理会功用 | profiling_history_size | 15 | --设置保存profiling的数量,缺省为15,局限为0至100,为0时将禁用p show profiles; 检察是不是开启,结果同上. 3.检察运用说明 help profile; 4.开启profile set profiling=1; 赋值时刻不要有过剩的空格. 5.运转sql,检察对应的profile select * from test ; show profiles; result: +----------+------------+--------------------------------------------------------------------------------------------------------------------------+ | Query_ID | Duration | Query | +----------+------------+--------------------------------------------------------------------------------------------------------------------------+ | 28 | 0.00033575 | select * from test | +----------+------------+--------------------------------------------------------------------------------------------------------------------------+ 理会sql机能,理会的时刻能够加上对应的开支字段 show profile [cpu,io][all] for query 28 ; show profile for query 28 ; +----------------------+----------+ | Status | Duration | +----------------------+----------+ | starting | 5.7E-5 | | checking permissions | 7E-6 | | Opening tables | 1.7E-5 | | init | 2.3E-5 | | System lock | 8E-6 | | optimizing | 5E-6 | | statistics | 1.1E-5 | | preparing | 9E-6 | | executing | 3E-6 | | Sending data | 8.8E-5 | | end | 5E-6 | | query end | 6E-6 | | closing tables | 5E-6 | | freeing items | 7.8E-5 | | cleaning up | 1.5E-5 | +----------------------+----------+ 6.封闭 set profiling=off;
以上就是Mysql运用profile理会sql开支的代码的细致内容,更多请关注ki4网别的相干文章!