summaryrefslogtreecommitdiff
path: root/sql/opt_range.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-04-14 16:13:35 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-04-14 16:13:35 +0300
commitccaec18b3934ee384296b4597bdf462fac66c5a4 (patch)
tree167d2ec1374cb4812165958db6fe3bd43619157b /sql/opt_range.cc
parente40ed0e881690ed072c28c0f4080a3cfb83e5d73 (diff)
parent26f0cd8afcbdceff22223d4c521c3ce73ee09fda (diff)
downloadmariadb-git-ccaec18b3934ee384296b4597bdf462fac66c5a4.tar.gz
Merge 10.1 into 10.2
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r--sql/opt_range.cc23
1 files changed, 17 insertions, 6 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 99508cf0b50..6663f092bc8 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -358,7 +358,8 @@ QUICK_RANGE_SELECT *get_quick_select(PARAM *param,uint index,
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);
+ double read_time,
+ bool ror_scans_required);
static
TRP_INDEX_INTERSECT *get_best_index_intersect(PARAM *param, SEL_TREE *tree,
double read_time);
@@ -2592,7 +2593,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
/* Get best 'range' plan and prepare data for making other plans */
if ((range_trp= get_key_scans_params(&param, tree, FALSE, TRUE,
- best_read_time)))
+ best_read_time, FALSE)))
{
best_trp= range_trp;
best_read_time= best_trp->read_cost;
@@ -4716,7 +4717,8 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge,
{
DBUG_EXECUTE("info", print_sel_tree(param, *ptree, &(*ptree)->keys_map,
"tree in SEL_IMERGE"););
- if (!(*cur_child= get_key_scans_params(param, *ptree, TRUE, FALSE, read_time)))
+ if (!(*cur_child= get_key_scans_params(param, *ptree, TRUE, FALSE,
+ read_time, TRUE)))
{
/*
One of index scans in this index_merge is more expensive than entire
@@ -5038,7 +5040,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);
+ read_time, TRUE);
}
DBUG_RETURN(trp);
@@ -6766,6 +6768,7 @@ 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
RETURN
Best range read plan
NULL if no plan found or error occurred
@@ -6774,7 +6777,8 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param,
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)
+ double read_time,
+ bool ror_scans_required)
{
uint idx, UNINIT_VAR(best_idx);
SEL_ARG *key_to_read= NULL;
@@ -6822,6 +6826,13 @@ static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree,
update_tbl_stats, &mrr_flags,
&buf_size, &cost);
+ if (ror_scans_required && !param->is_ror_scan &&
+ !optimizer_flag(param->thd, OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION))
+ {
+ /* The scan is not a ROR-scan, just skip it */
+ continue;
+ }
+
if (found_records != HA_POS_ERROR && tree->index_scans &&
(index_scan= (INDEX_SCAN_INFO *)alloc_root(param->mem_root,
sizeof(INDEX_SCAN_INFO))))
@@ -9069,7 +9080,7 @@ key_and(RANGE_OPT_PARAM *param, SEL_ARG *key1, SEL_ARG *key2, uint clone_flag)
if (key2->next_key_part)
{
key1->use_count--; // Incremented in and_all_keys
- return and_all_keys(param, key1, key2, clone_flag);
+ return and_all_keys(param, key1, key2->next_key_part, clone_flag);
}
key2->use_count--; // Key2 doesn't have a tree
}