作者微信:gp_22389860
btr_estimate_n_rows_in_range_low 函数用于非唯一访问的行数评估也就是在执行计划生成阶段会去访问实际的数据,尽可能的得到正确的执行计划,这个过程叫做dive。其和参数eq_range_index_dive_limit有关,如果参数设置1那么将禁用dive功能,使用统计数据进行执行计划的生成。但某些时候MySQL 5.7根据统计数据并不能得到正确的执行计划,因此才有了dive,但是dive会产生额外的代价,这个过程是需要实际访问数据块的。
常用的比如非唯一索引的数据访问,还有>
然后通过btr_cur_search_to_nth_level函数定位到终点记录通过cursor获取到path,假设起点的path为path1 终点的path为path2path为一个数组,其中保存了查询的路径,然后会循环的从顶层节点到叶子节点进行判断,其中包含了
/** A slot in the path array. We store here info on a search path down the
tree. Each slot contains data on a single level of the tree. */
struct btr_path_t {
/* Assume a page like:
records: (inf, a, b, c, d, sup)
index of the record: 0, 1, 2, 3, 4, 5
*/
/** Index of the record where the page cursor stopped on this level
(index in alphabetical order). V