commit c8cc85910054c535df1c88b263a6d4ed28eaa940 Author: kaiwang.ckw Date: Tue Nov 3 19:28:29 2020 +0800 BUG#101430 INVALID NUMBER 2e308 IN OPT TRACE FOR FORCE INDEX diff --git a/sql/opt_range.cc b/sql/opt_range.cc index ce19c58..85dd9ab 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -3909,6 +3909,13 @@ int test_quick_select(THD *thd, Key_map keys_to_use, table_map prev_tables, Cost_estimate cost_est = head->file->table_scan_cost(); cost_est.add_io(1.1); cost_est.add_cpu(scan_time); + + Opt_trace_context *const trace = &thd->opt_trace; + Opt_trace_object trace_range(trace, "range_analysis"); + Opt_trace_object(trace, "table_scan") + .add("rows", head->file->stats.records) + .add("cost", cost_est); + if (head->force_index) { scan_time = DBL_MAX; cost_est.set_max_cost(); @@ -3922,12 +3929,6 @@ int test_quick_select(THD *thd, Key_map keys_to_use, table_map prev_tables, } else if (cost_est.total_cost() <= 2.0 && !force_quick_range) DBUG_RETURN(0); /* No need for quick select */ - Opt_trace_context *const trace = &thd->opt_trace; - Opt_trace_object trace_range(trace, "range_analysis"); - Opt_trace_object(trace, "table_scan") - .add("rows", head->file->stats.records) - .add("cost", cost_est); - keys_to_use.intersect(head->keys_in_use_for_query); if (!keys_to_use.is_clear_all()) { MEM_ROOT alloc;