Description:
the comment of get_best_ror_intersect:
"
find_min_ror_intersection_scan()
{
R= select all ROR scans;
order R by (E(#records_matched) * key_record_length).
S= first(R); -- set of scans that will be used for ROR-
R= R-first(S);
min_cost= cost(S);
min_scan= make_scan(S);
while (R is not empty)
{
firstR= R - first(R);
if (!selectivity(S + firstR < selectivity(S)))
continue;
S= S + first(R);
if (cost(S) < min_cost)
{
min_cost= cost(S);
min_scan= make_scan(S);
}
}
return min_scan;
}
"
According to the logic of the get_best_ror_intersect, the “selectivity(S + firstR < selectivity(S))” should be fixed as “if (!selectivity(S + firstR) < selectivity(S))”.
the following code correspond the while loop in comment above.
"
while (cur_ror_scan != tree->ror_scans_end && !intersect->is_covering) {
/* some codes */
/* S= S + first(R); R= R - first(R); */
if (!ror_intersect_add(intersect, needed_fields, *cur_ror_scan, false,
&trace_idx,
force_index_merge && !use_cheapest_index_merge)) {
/* some codes */
continue;
}
/* some codes */
}
"
How to repeat:
Analyze the logic of get_best_ror_intersect.
Suggested fix:
the comment “selectivity(S + firstR < selectivity(S))” should be fixed as “if (!selectivity(S + firstR) < selectivity(S))”.