mysql中cost对比测试
1.数据库表
复制表
2.执行select c_id from customer where c_discount = 0.35;后,explain对比
3.optimizer_trace比较
原表
{"steps": [{"join_preparation": {"select#": 1,"steps": [{"expanded_query": "/* select#1 */ select `customer`.`c_id` AS `c_id` from `customer` where (`customer`.`c_discount` = 0.35)"}]}},{"join_optimization": {"select#": 1,"steps": [{"condition_processing": {"condition": "WHERE","original_condition": "(`customer`.`c_discount` = 0.35)","steps": [{"transformation": "equality_propagation","resulting_condition": "multiple equal(0.35, `customer`.`c_discount`)"},{"transformation": "constant_propagation","resulting_condition": "multiple equal(0.35, `customer`.`c_discount`)"},{"transformation": "trivial_condition_removal","resulting_condition": "multiple equal(0.35, `customer`.`c_discount`)"}]}},{"substitute_generated_columns": {}},{"table_dependencies": [{"table": "`customer`","row_may_be_null": false,"map_bit": 0,"depends_on_map_bits": []}]},{"ref_optimizer_key_uses": []},{"rows_estimation": [{"table": "`customer`","table_scan": {"rows": 289371,"cost": 11504}}]},{"considered_execution_plans": [{"plan_prefix": [],"table": "`customer`","best_access_path": {"considered_access_paths": [{"rows_to_scan": 289371,"filtering_effect": [],"final_filtering_effect": 0.1,"access_type": "scan","resulting_rows": 28937,"cost": 40441,"chosen": true}]},"condition_filtering_pct": 100,"rows_for_plan": 28937,"cost_for_plan": 40441,"chosen": true}]},{"attaching_conditions_to_tables": {"original_condition": "(`customer`.`c_discount` = 0.35)","attached_conditions_computation": [],"attached_conditions_summary": [{"table": "`customer`","attached": "(`customer`.`c_discount` = 0.35)"}]}},{"refine_plan": [{"table": "`customer`"}]}]}},{"join_explain": {"select#": 1,"steps": []}}]
}
复制表
{"steps": [{"join_preparation": {"select#": 1,"steps": [{"expanded_query": "/* select#1 */ select `customer_new`.`c_id` AS `c_id` from `customer_new` where (`customer_new`.`c_discount` = 0.35)"}]}},{"join_optimization": {"select#": 1,"steps": [{"condition_processing": {"condition": "WHERE","original_condition": "(`customer_new`.`c_discount` = 0.35)","steps": [{"transformation": "equality_propagation","resulting_condition": "multiple equal(0.35, `customer_new`.`c_discount`)"},{"transformation": "constant_propagation","resulting_condition": "multiple equal(0.35, `customer_new`.`c_discount`)"},{"transformation": "trivial_condition_removal","resulting_condition": "multiple equal(0.35, `customer_new`.`c_discount`)"}]}},{"substitute_generated_columns": {}},{"table_dependencies": [{"table": "`customer_new`","row_may_be_null": false,"map_bit": 0,"depends_on_map_bits": []}]},{"ref_optimizer_key_uses": [{"table": "`customer_new`","field": "c_discount","equals": "0.35","null_rejecting": false}]},{"rows_estimation": [{"table": "`customer_new`","range_analysis": {"table_scan": {"rows": 285901,"cost": 41760},"potential_range_indexes": [{"index": "PRIMARY","usable": false,"cause": "not_applicable"},{"index": "c_d_1","usable": true,"key_parts": ["c_discount","c_w_id","c_d_id","c_id"]}],"best_covering_index_scan": {"index": "c_d_1","cost": 28939,"chosen": true},"setup_range_conditions": [],"group_index_range": {"chosen": false,"cause": "not_group_by_or_distinct"},"analyzing_range_alternatives": {"range_scan_alternatives": [{"index": "c_d_1","ranges": ["0.35 <= c_discount <= 0.35"],"index_dives_for_eq_ranges": true,"rowid_ordered": true,"using_mrr": false,"index_only": true,"rows": 5822,"cost": 590.29,"chosen": true}],"analyzing_roworder_intersect": {"usable": false,"cause": "too_few_roworder_scans"}},"chosen_range_access_summary": {"range_access_plan": {"type": "range_scan","index": "c_d_1","rows": 5822,"ranges": ["0.35 <= c_discount <= 0.35"]},"rows_for_plan": 5822,"cost_for_plan": 590.29,"chosen": true}}}]},{"considered_execution_plans": [{"plan_prefix": [],"table": "`customer_new`","best_access_path": {"considered_access_paths": [{"access_type": "ref","index": "c_d_1","rows": 5822,"cost": 590.28,"chosen": true},{"access_type": "range","range_details": {"used_index": "c_d_1"},"chosen": false,"cause": "heuristic_index_cheaper"}]},"condition_filtering_pct": 100,"rows_for_plan": 5822,"cost_for_plan": 590.28,"chosen": true}]},{"attaching_conditions_to_tables": {"original_condition": "(`customer_new`.`c_discount` = 0.35)","attached_conditions_computation": [],"attached_conditions_summary": [{"table": "`customer_new`","attached": null}]}},{"refine_plan": [{"table": "`customer_new`"}]}]}},{"join_explain": {"select#": 1,"steps": []}}]
}
其中原表的cost
带索引表中table_scan的值
mysql中cost对比测试相关推荐
- mysql可串行化读音,Oracle与MySQL中“可串行化”的对比测试
Oracle与MySQL中"可串行化"的对比测试 Oracle与MySQL中"可串行化"的对比测试 Thomas Kyte 在"Oracle 9i&a ...
- 面试mysql中怎么创建索引_阿里面试:MySQL如何设计索引更高效?
有情怀,有干货,微信搜索[三太子敖丙]关注这个不一样的程序员. 本文 GitHub https://github.com/JavaFamily 已收录,有一线大厂面试完整考点.资料以及我的系列文章. ...
- inlfuxdb版本_InfluxDB和MySQL的读写对比测试
今天进行了InfluxDB和MySQL的读写对比测试,这里记录下结果,也方便我以后查阅. 操作系统: CentOS6.5_x64 InfluxDB版本 : v1.1.0 MySQL版本:v5.1.73 ...
- influxdb mysql对比_InfluxDB和MySQL的读写对比测试
今天进行了InfluxDB和MySQL的读写对比测试,这里记录下结果,也方便我以后查阅. 操作系统: CentOS6.5_x64 InfluxDB版本 : v1.1.0 MySQL版本:v5.1.73 ...
- mysql join 索引 无效_ORACLE MYSQL中join 字段类型不同索引失效的情况-阿里云开发者社区...
ORACLE MYSQL中join 字段类型不同索引失效的情况 重庆八怪 2016-12-29 780浏览量 简介: 关于JOIN使用不同类型的字段类型,数据库可能进行隐士转换,MYSQL ORACL ...
- mysql+last_query_cost_辛星简译MySQL中的last_query_cost_MySQL
我们都知道在MySQL中可以通过show status like 'last_query_cost' 来查看查上一个查询的代价,而且它是io_cost和cpu_cost的开销总和,它通常也是我们评价一 ...
- mysql+last_query_cost_辛星简译MySQL中的last_query_cost
我们都知道在MySQL中可以通过show status like 'last_query_cost' 来查看查上一个查询的代价,而且它是io_cost和cpu_cost的开销总和,它通常也是我 ...
- 【面朝大厂】面试官:你对MySQL中的索引了解多少?
点击上方"Java基基",选择"设为星标" 做积极的人,而不是积极废人! 源码精品专栏 原创 | Java 2020 超神之路,很肝~ 中文详细注释的开源项目 ...
- 面试官:你对MySQL中的索引了解多少?
前言 因为现在使用的mysql默认存储引擎是Innodb,所以本篇文章重点讲述Innodb下的索引, 顺带简单讲述其他引擎.希望小伙伴们能通过这片文章对mysql的索引有更加清晰的认识,废话不多说,我 ...
- 你对MySQL中的索引了解多少?
前言 因为现在使用的mysql默认存储引擎是Innodb,所以本篇文章重点讲述Innodb下的索引, 顺带简单讲述其他引擎.希望小伙伴们能通过这篇文章对mysql的索引有更加清晰的认识,废话不多说,我 ...
最新文章
- 合并两个对象 java_在Java中合并两个对象列表8
- Linux下如何查看系统启动时间和运行时间(转)
- [笔记]ndarray切片(python)
- 【采用】智能反欺诈算法概览及典型应用案例
- Node.js 8有哪些重要功能和修复?
- Tomcat端口占用相关的问题
- mysql 转成树_Mysql树型结构2种方式及相互转换
- Repeater绑定数据库
- Python实现AI贪吃蛇
- 远程服务器mstsc命令,远程桌面连接命令mstsc怎么用
- 数据库实验四 视图实验
- 互联网晚报 | 11月18日 星期四 | 看点直播将于11月30日停止服务;B站月活用户达2.67亿;高通宣布进军汽车领域...
- 基于区块链的数字藏品管控方案
- 安卓巴士精选Android开发教程
- 查找一个字符串中的所有子串的位置
- 【机器学习】阿里云天池竞赛——工业蒸汽量预测(6)
- android电视原理图,电视机的基本工作原理及结构组成
- 【USB笔记】查询VID对应的USB设备厂商
- android 闹钟运行原理,简单 闹钟 实现 原理
- 还在手动测试?那是那还不知道Python自动化测试的强大之处