information_schema.optimizer_trace 用于追踪优化器的优化过程;
通常来说这张表中是没有数据的,要想开户追踪要把 @@session.optimizer_trace='enabled=on,one_line=on'

information_schema.optimizer_trace表的常用列:
  1、query :查询语句
  2、trace :查询的追踪信息

例子:
  1、没有打开@@session.optmizer_trace='enabled=on,one_line=on'时information_schema.optimizer_trace表是空的

 select * from information_schema.optimizer_trace;

  2、打开

set @@session.optimizer_trace='enabled=on,one_line=on';

  3、执行查询

select user,host from mysql.user;
+------------+------------+
| user | host |
+------------+------------+
| admin | % |
| zabbix | % |
| backupuser | 127.0.0.1 |
| root | 127.0.0.1 |
| zabbix | 127.0.0.1 |
| root | ::1 |
| | localhost |
| backupuser | localhost |
| root | localhost |
| zabbix | localhost |
| | workstudio |
| root | workstudio |
+------------+------------+

  4、查看优化器信息

select * from information_schema.optimizer_trace \G
*************************** 1. row ***************************
QUERY: select user,host from mysql.user
TRACE: {"steps": [{"join_preparation": {"select#": 1,"steps": [{"expanded_query": "/* select#1 */ select `mysql`.`user`.`User` AS `user`,`mysql`.`user`.`Host` AS `host` from `mysql`.`user`"}]}},{"join_optimization": {"select#": 1,"steps": [{"table_dependencies": [{"table": "`mysql`.`user`","row_may_be_null": false,"map_bit": 0,"depends_on_map_bits": []}]},{"rows_estimation": [{"table": "`mysql`.`user`","table_scan": {"rows": 12,"cost": 2}}]},{"considered_execution_plans": [{"plan_prefix": [],"table": "`mysql`.`user`","best_access_path": {"considered_access_paths": [{"access_type": "scan","rows": 12,"cost": 4.6813,"chosen": true}]},"cost_for_plan": 4.6813,"rows_for_plan": 12,"chosen": true}]},{"attaching_conditions_to_tables": {"original_condition": null,"attached_conditions_computation": [],"attached_conditions_summary": [{"table": "`mysql`.`user`","attached": null}]}},{"refine_plan": [{"table": "`mysql`.`user`","access_type": "index_scan"}]}]}},{"join_execution": {"select#": 1,"steps": []}}]}
MISSING_BYTES_BEYOND_MAX_MEM_SIZE: 0
INSUFFICIENT_PRIVILEGES: 0
1 row in set (0.00 sec)

information_schema.optimizer_trace学习的更多相关文章

  1. information_schema.referential_constraints 学习

    information_schema.referential_constraints 表用于查看外键约束 1.information_schema.referential_constraints表的常 ...

  2. information_schema.profiling学习

    information_schema.profiling可以用来分析每一条SQL在它执行的各个阶段的用时,注意这个表是session 级的,也就是说如果session1 开启了它:session2没有 ...

  3. information_schema.triggers 学习

    mysql实例中的每一个trigger 对应到information_schema.triggers 中有一行 1.information_schema.triggers 表的常用列: 1.trigg ...

  4. information_schema.routines 学习

    information_schema.routines 用户查看mysql中的routine信息 1.information_schema.routines 表中的常用列: 1.

  5. information_schema.key_column_usage 学习

    information_schema.key_column_usage 表可以查看索引列上的约束: 1.information_schema.key_column_usage 的常用列: 1.cons ...

  6. information_schema.events 学习

    information_schema.events 表保存了整个mysql实例中的event 信息 1.常用列: 1.event_catalog :永远是def 2.event_schema :eve ...

  7. information_schema.engines学习

    当前mysql实例的存储引擎信息可以从information_schema.engines 中查询到 例子: mysql> select * from information_schema.en ...

  8. information_schema.column_privileges 学习

    mysql 的授权是分层次的 实例级 | 库级 | 表级 | 列级 而这些授权信息被保存在了mysql.user | mysql.db | mysql.tables_priv | mysql.colu ...

  9. information_schema.columns 学习

    每一个表中的每一列都会在information_schema.columns表中对应一行 1.informaiton_schema.columns 常用列: 1.table_catalog :不管是t ...

随机推荐

  1. angular--bootstrap实例日期控件【datepicker】

    head部分: <!--Bootstrap--> <link rel="stylesheet" href="/supProdom/script/boot ...

  2. nginx日志管理与限速

    1.日志简介nginx日志主要有两种:访问日志和错误日志.访问日志主要记录客户端访问nginx的每一个请求,格式可以自定义:错误日志主要记录客户端访问nginx出错时的日志,格式不支持自定义.两种日志 ...

  3. 《Programming WPF》翻译 第5章 1.不使用样式

    原文:<Programming WPF>翻译 第5章 1.不使用样式 作为一个样式如何使其在WPF使用的例子,,让我们看一下TTT简单的实现,如示例5-1. 示例5-1 <!-- W ...

  4. mysql导入到elasticsearch

    JDBC importer for Elasticsearch Java Database 连接(JDBC) 导入运行获取数据从JDBC 源 安装: 1.在下面的步骤 替换<version> ...

  5. bzoj1751 [Usaco2005 qua]Lake Counting

    1751: [Usaco2005 qua]Lake Counting Time Limit: 5 Sec  Memory Limit: 64 MB Submit: 168  Solved: 130 [ ...

  6. libeXosip2(1) -- Modules

    Modules Here is a list of all modules: [detail level 12] The eXtented eXosip stack LibeXosip2 Versio ...

  7. Palindrome Partitioning 解答

    Question Given a string s, partition s such that every substring of the partition is a palindrome. R ...

  8. WPF动画

    System.Windows.Media.Animation 这个命名空间中,包含了三种动画类:线性插值动画类(17个).关键帧动画(22个).路径动画(3个). 线性插值动画类(17个)如下: By ...

  9. python高级编程之选择好名称:命名指南

    # # -*- coding: utf-8 -*- # # python:2.x # __author__ = 'Administrator' #命名指南 #一组常用的命名规则可以被应用到变量,方法函 ...

  10. How to check for and disable Java in OS X

    Java used to be deeply embedded in OS X, but in recent versions of the OS it's an optional install. ...