diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_priv.h | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 7 | ||||
-rw-r--r-- | sql/sql_sort_nest.cc | 9 |
3 files changed, 10 insertions, 8 deletions
diff --git a/sql/sql_priv.h b/sql/sql_priv.h index e9c5f328cda..bb8b42196f5 100644 --- a/sql/sql_priv.h +++ b/sql/sql_priv.h @@ -265,7 +265,7 @@ OPTIMIZER_SWITCH_COND_PUSHDOWN_FOR_SUBQUERY | \ OPTIMIZER_SWITCH_USE_ROWID_FILTER | \ OPTIMIZER_SWITCH_COND_PUSHDOWN_FROM_HAVING | \ - OPTIMIZER_SWITCH_OPTIMIZE_JOIN_BUFFER_SIZE | + OPTIMIZER_SWITCH_OPTIMIZE_JOIN_BUFFER_SIZE | \ OPTIMIZER_SWITCH_COST_BASED_ORDER_BY_LIMIT) /* diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 827c272b1ce..7dd7e8dc438 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8229,6 +8229,8 @@ best_access_path(JOIN *join, join->sort_by_table= (TABLE*) 1; // Must use temporary table } + trace_access_scan.end(); + /* Use the estimate of rows read for a table for range/table scan from TABLE::quick_condition_rows. This is due to the reason @@ -8297,7 +8299,6 @@ best_access_path(JOIN *join, pos->sort_nest_operation_here= FALSE; pos->index_no= index_picked; - trace_access_scan.end(); trace_paths.end(); loose_scan_opt.save_to_position(s, loose_scan_pos); @@ -13923,7 +13924,7 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) sort_nest_info->index_used >= 0) { tab->index= sort_nest_info->index_used; - tab->limit= tab->records_read; + tab->limit= (ha_rows)tab->records_read; } else tab->index=find_shortest_key(table, &table->covering_keys); @@ -29140,7 +29141,7 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table, } /* group */ find_cost_of_index_with_ordering(thd, tab, table, &select_limit, - fanout, refkey_rows_estimate, + fanout, (double) refkey_rows_estimate, nr, &index_scan_time, &possible_key); diff --git a/sql/sql_sort_nest.cc b/sql/sql_sort_nest.cc index 6fd0958f179..aa1046eef53 100644 --- a/sql/sql_sort_nest.cc +++ b/sql/sql_sort_nest.cc @@ -1062,7 +1062,7 @@ int get_best_index_for_order_by_limit(JOIN_TAB *tab, { best_index= idx; *read_time= index_scan_time; - *records= select_limit; + *records= (double)select_limit; } } considered_indexes.end(); @@ -1198,6 +1198,7 @@ void JOIN::setup_range_scan(JOIN_TAB *tab, uint idx, double records) int err, rc, direction; uint used_key_parts; key_map keymap_for_range; + Json_writer_object wrapper(thd); Json_writer_array forcing_range(thd, "range_scan_for_order_by_limit"); sel= make_select(tab->table, const_table_map, const_table_map, @@ -1257,7 +1258,7 @@ void JOIN::setup_range_scan(JOIN_TAB *tab, uint idx, double records) taken selectivity of limit into account. */ if (sort_nest_possible && records < tab->quick->records) - tab->quick->records= records; + tab->quick->records= (ha_rows)records; sel->quick= NULL; @@ -1557,7 +1558,7 @@ void find_cost_of_index_with_ordering(THD *thd, const JOIN_TAB *tab, KEY *keyinfo= table->key_info + nr; ha_rows select_limit= *select_limit_arg; double rec_per_key; - double table_records= table->stat_records(); + ha_rows table_records= table->stat_records(); /* If tab=tk is not the last joined table tn then to get first L records from the result set we can expect to retrieve @@ -1599,7 +1600,7 @@ void find_cost_of_index_with_ordering(THD *thd, const JOIN_TAB *tab, */ if (select_limit > est_best_records) - select_limit= table_records; + select_limit= (ha_rows) table_records; else select_limit= (ha_rows) (select_limit * (double) table_records / |