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. MySQL查看当前连接数、连接数和最大连接数

    MySQL查看当前所有连接的详细资料: mysqladmin -u root -p processlist MySQL查看当前连接数(Threads为连接数) mysqladmin -u root - ...

  2. IOS 面试 --- 动画 block

    1 谈谈对Block 的理解?并写出一个使用Block执行UIVew动画? 答案:Block是可以获取其他函数局部变量的匿名函数,其不但方便开发,并且可以大幅提高应用的执行效率(多核心CPU可直接处理 ...

  3. [HDU] 1394 Minimum Inversion Number [线段树求逆序数]

    Minimum Inversion Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java ...

  4. PowerShell官方的MSDN

    https://msdn.microsoft.com/en-us/powershell/mt173057.aspx 官方还咋github上放置了  扩展模块. 比如 web iis部署.sqlserv ...

  5. Integer to English Words 解答

    Question Convert a non-negative integer to its english words representation. Given input is guarante ...

  6. add BOM to fix UTF-8 in Excel

    fputs($fp, $bom =( chr(0xEF) . chr(0xBB) . chr(0xBF) ));

  7. IOS 用drawRect 画表格

    自定义一个View DrawLine DrawLine.h #import <UIKit/UIKit.h> @protocol gridTouchDelete <NSObject&g ...

  8. 图的最小生成树(Prim、Kruskal)

    理论: Prim: 基本思想:假设G=(V,E)是连通的,TE是G上最小生成树中边的集合.算法从U={u0}(u0∈V).TE={}开始.重复执行下列操作: 在所有u∈U,v∈V-U的边(u,v)∈E ...

  9. Spark函数详解系列之RDD基本转换

    摘要:   RDD:弹性分布式数据集,是一种特殊集合 ‚ 支持多种来源 ‚ 有容错机制 ‚ 可以被缓存 ‚ 支持并行操作,一个RDD代表一个分区里的数据集   RDD有两种操作算子:         ...

  10. java与.net比较学习系列(3) 基本数据类型和类型转换

    在Java中,数据类型分为两类,一类是基本数据类型,另外一类是引用类型. 而在C#中,数据类型分为三类,分别是基元类型,值类型和引用类型.其中基元类型是.net framework框架中预定义的类型, ...