summaryrefslogtreecommitdiff
path: root/sql/opt_range.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-04-22 18:18:51 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-04-22 18:18:51 +0300
commit88cf6f1c7ff5d56138c8b53a5adaca4c61752f86 (patch)
treeeee8eed7e9388a575de4d9c948b0706e2356d694 /sql/opt_range.cc
parent498c5e2be1021569c1d5554bcb91f45090e30d4b (diff)
parent455cf6196c8c73f5a50004ac7f31a9be8ac14bbe (diff)
downloadmariadb-git-88cf6f1c7ff5d56138c8b53a5adaca4c61752f86.tar.gz
Merge 10.3 into 10.4
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r--sql/opt_range.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 899d1fc9782..312999ddc17 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -5044,8 +5044,8 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge,
double roru_index_costs;
ha_rows roru_total_records;
double roru_intersect_part= 1.0;
- double limit_read_time= read_time;
size_t n_child_scans;
+ double limit_read_time= read_time;
THD *thd= param->thd;
DBUG_ENTER("get_best_disjunct_quick");
DBUG_PRINT("info", ("Full table scan cost: %g", read_time));
@@ -5072,6 +5072,10 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge,
sizeof(TRP_RANGE*)*
n_child_scans)))
DBUG_RETURN(NULL);
+
+ const bool only_ror_scans_required= !optimizer_flag(param->thd,
+ OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION);
+
Json_writer_object trace_best_disjunct(thd);
Json_writer_array to_merge(thd, "indexes_to_merge");
/*
@@ -5087,7 +5091,8 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge,
"tree in SEL_IMERGE"););
Json_writer_object trace_idx(thd);
if (!(*cur_child= get_key_scans_params(param, *ptree, TRUE, FALSE,
- read_time, TRUE)))
+ read_time,
+ only_ror_scans_required)))
{
/*
One of index scans in this index_merge is more expensive than entire
@@ -5449,7 +5454,7 @@ TABLE_READ_PLAN *merge_same_index_scans(PARAM *param, SEL_IMERGE *imerge,
index merge retrievals are not well calibrated
*/
trp= get_key_scans_params(param, *imerge->trees, FALSE, TRUE,
- read_time, TRUE);
+ read_time, FALSE);
}
DBUG_RETURN(trp);
@@ -7333,7 +7338,8 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param,
index_read_must_be_used if TRUE, assume 'index only' option will be set
(except for clustered PK indexes)
read_time don't create read plans with cost > read_time.
- ror_scans_required set to TRUE for index merge
+ only_ror_scans_required set to TRUE when we are only interested
+ in ROR scan
RETURN
Best range read plan
NULL if no plan found or error occurred
@@ -7343,7 +7349,7 @@ static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree,
bool index_read_must_be_used,
bool update_tbl_stats,
double read_time,
- bool ror_scans_required)
+ bool only_ror_scans_required)
{
uint idx, UNINIT_VAR(best_idx);
SEL_ARG *key_to_read= NULL;
@@ -7397,8 +7403,7 @@ static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree,
found_records= check_quick_select(param, idx, read_index_only, key,
update_tbl_stats, &mrr_flags,
&buf_size, &cost, &is_ror_scan);
- if (ror_scans_required && !is_ror_scan &&
- !optimizer_flag(param->thd, OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION))
+ if (only_ror_scans_required && !is_ror_scan)
continue;
if (found_records != HA_POS_ERROR && tree->index_scans &&