Mysql动态打开日志 show profiles详细信息
2015-08-11 23:19
676 查看
查看表索引 show index from t_user; show keys from t_user; 动态打开general 日志 show global variables like '%general%'; set global general_log = on; 动态打开slow 日志 show global variables like '%slow%'; set global slow_query_log = on; set global long_query_time = 0.2; set profiling = on; 或set profiling = 1; reset query cache show profile ; show profiles; mysql> select @@profiling; +-------------+ | @@profiling | +-------------+ | 0 | +-------------+ show profiles; +----------+----------+-------------------------------------+ | Query_ID | Duration | Query | +----------+----------+-------------------------------------+ | 0 | 0.000045 | set profiling = 1 | | 1 | 0.000071 | select @@profiling | | 2 | 0.000087 | drop table if exists t1 | | 3 | 0.031741 | create table t1 (id int not null) | | 4 | 0.000615 | insert into t1 values (1), (2), (3) | | 5 | 0.000198 | select * from t1 | +----------+----------+-------------------------------------+ 根据query_id 查看某个查询的详细时间耗费 mysql> show profile for query 2; +----------------------+----------+ | Status | Duration | +----------------------+----------+ | starting | 0.000231 | | checking permissions | 0.000015 | | checking permissions | 0.000010 | | checking permissions | 0.000010 | | checking permissions | 0.000014 | | Opening tables | 0.000118 | | init | 0.000051 | | System lock | 0.000023 | | optimizing | 0.000012 | | optimizing | 0.000019 | | statistics | 0.000039 | | preparing | 0.000034 | | Sorting result | 0.000029 | | statistics | 0.000070 | | preparing | 0.000034 | | Creating tmp table | 0.000038 | | Sorting result | 0.000048 | | executing | 0.000025 | | Sending data | 0.016414 | | executing | 0.000015 | | Sending data | 0.536580 | | Creating sort index | 0.000353 | | end | 0.000014 | | removing tmp table | 0.000018 | | end | 0.000014 | | query end | 0.000017 | | closing tables | 0.000011 | | removing tmp table | 0.000176 | | closing tables | 0.000031 | | freeing items | 0.001331 | | logging slow query | 0.000084 | | cleaning up | 0.000028 | +----------------------+----------+ 32 rows in set, 1 warning (0.00 sec) mysql> show profile cpu for query 2; +----------------------+----------+----------+------------+ | Status | Duration | CPU_user | CPU_system | +----------------------+----------+----------+------------+ | starting | 0.000231 | 0.000000 | 0.000000 | | checking permissions | 0.000015 | 0.000000 | 0.000000 | | checking permissions | 0.000010 | 0.000000 | 0.000000 | | checking permissions | 0.000010 | 0.000000 | 0.000000 | | checking permissions | 0.000014 | 0.000000 | 0.000000 | | Opening tables | 0.000118 | 0.000000 | 0.000000 | | init | 0.000051 | 0.000000 | 0.000000 | | System lock | 0.000023 | 0.000000 | 0.000000 | | optimizing | 0.000012 | 0.000000 | 0.000000 | | optimizing | 0.000019 | 0.000000 | 0.000000 | | statistics | 0.000039 | 0.000000 | 0.000000 | | preparing | 0.000034 | 0.000000 | 0.000000 | | Sorting result | 0.000029 | 0.000000 | 0.000000 | | statistics | 0.000070 | 0.000000 | 0.000000 | | preparing | 0.000034 | 0.000000 | 0.000000 | | Creating tmp table | 0.000038 | 0.000000 | 0.000000 | | Sorting result | 0.000048 | 0.000000 | 0.000000 | | executing | 0.000025 | 0.000000 | 0.000000 | | Sending data | 0.016414 | 0.015998 | 0.000000 | | executing | 0.000015 | 0.000000 | 0.000000 | | Sending data | 0.536580 | 0.539917 | 0.000000 | | Creating sort index | 0.000353 | 0.000000 | 0.000000 | | end | 0.000014 | 0.000000 | 0.000000 | | removing tmp table | 0.000018 | 0.000000 | 0.000000 | | end | 0.000014 | 0.000000 | 0.000000 | | query end | 0.000017 | 0.000000 | 0.000000 | | closing tables | 0.000011 | 0.000000 | 0.000000 | | removing tmp table | 0.000176 | 0.000000 | 0.000000 | | closing tables | 0.000031 | 0.000000 | 0.000000 | | freeing items | 0.001331 | 0.001000 | 0.000000 | | logging slow query | 0.000084 | 0.000000 | 0.000000 | | cleaning up | 0.000028 | 0.000000 | 0.000000 | +----------------------+----------+----------+------------+ 32 rows in set, 1 warning (0.00 sec) mysql> show profile source for query 2; +----------------------+----------+---------------------------+------------------+-------------+ | Status | Duration | Source_function | Source_file | Source_line | +----------------------+----------+---------------------------+------------------+-------------+ | starting | 0.000231 | NULL | NULL | NULL | | checking permissions | 0.000015 | check_access | sql_parse.cc | 5297 | | checking permissions | 0.000010 | check_access | sql_parse.cc | 5297 | | checking permissions | 0.000010 | check_access | sql_parse.cc | 5297 | | checking permissions | 0.000014 | check_access | sql_parse.cc | 5297 | | Opening tables | 0.000118 | open_tables | sql_base.cc | 5069 | | init | 0.000051 | mysql_prepare_select | sql_select.cc | 1050 | | System lock | 0.000023 | mysql_lock_tables | lock.cc | 304 | | optimizing | 0.000012 | optimize | sql_optimizer.cc | 138 | | optimizing | 0.000019 | optimize | sql_optimizer.cc | 138 | | statistics | 0.000039 | optimize | sql_optimizer.cc | 362 | | preparing | 0.000034 | optimize | sql_optimizer.cc | 485 | | Sorting result | 0.000029 | make_tmp_tables_info | sql_select.cc | 5307 | | statistics | 0.000070 | optimize | sql_optimizer.cc | 362 | | preparing | 0.000034 | optimize | sql_optimizer.cc | 485 | | Creating tmp table | 0.000038 | create_intermediate_table | sql_executor.cc | 210 | | Sorting result | 0.000048 | make_tmp_tables_info | sql_select.cc | 5307 | | executing | 0.000025 | exec | sql_executor.cc | 110 | | Sending data | 0.016414 | exec | sql_executor.cc | 190 | | executing | 0.000015 | exec | sql_executor.cc | 110 | | Sending data | 0.536580 | exec | sql_executor.cc | 190 | | Creating sort index | 0.000353 | sort_table | sql_executor.cc | 2504 | | end | 0.000014 | mysql_execute_select | sql_select.cc | 1105 | | removing tmp table | 0.000018 | free_tmp_table | sql_tmp_table.cc | 1868 | | end | 0.000014 | free_tmp_table | sql_tmp_table.cc | 1897 | | query end | 0.000017 | mysql_execute_command | sql_parse.cc | 4996 | | closing tables | 0.000011 | mysql_execute_command | sql_parse.cc | 5044 | | removing tmp table | 0.000176 | free_tmp_table | sql_tmp_table.cc | 1868 | | closing tables | 0.000031 | free_tmp_table | sql_tmp_table.cc | 1897 | | freeing items | 0.001331 | mysql_parse | sql_parse.cc | 6433 | | logging slow query | 0.000084 | log_slow_do | sql_parse.cc | 1874 | | cleaning up | 0.000028 | dispatch_command | sql_parse.cc | 1778 | +----------------------+----------+---------------------------+------------------+-------------+ 32 rows in set, 1 warning (0.00 sec)
相关文章推荐
- ubuntu mysql 备份 卸载 升级
- 进行mysql压力测试需要注意的几点
- mysql show grants查看权限
- mysql命令
- 【MySql】使用记录<五>
- MySQL 数据库ut8mb4字符集
- 5步轻松搞定windows系统下mysql命令行操作,完成简单mysql配置
- MySQL的分页
- MySQL建议列属性尽量为NOT NULL
- MySQL数据库事务隔离级别(Transaction Isolation Level)
- Unity3D 连接MySQL数据库笔记4-Unity3d代码
- MYSQL隔离级别介绍
- what-to-tune-in-mysql-56-after-installation.html
- Mysql全文本检索-MyISM引擎,Where子句中使用Match() Against()-布尔模式
- 数据库MySQL操作
- mysql中如何复制一行数据
- 修改mysql的默认存储引擎为InnoDB
- 通过saltstack源码安装mysql
- MySQL必知必会笔记(六)插入数据 创建和操纵表
- mysql主从灾备