diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2022-08-08 17:12:32 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2022-08-08 17:12:32 +0200 |
commit | 1d480419822b53c840de54542c1d1a0851dbe2c8 (patch) | |
tree | 629aabba2d52741b4075c3e345396bd989516cb2 /sql/opt_range.cc | |
parent | 3ebbfd88a0360938e3a5a480265beb2a71b1268a (diff) | |
parent | 4f54c219e7c73072d7eff1e81e0f51dc1ff47509 (diff) | |
download | mariadb-git-1d480419822b53c840de54542c1d1a0851dbe2c8.tar.gz |
Merge branch '10.6' into 10.7
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r-- | sql/opt_range.cc | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 7909f5b35f9..28d98ea5ced 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1901,7 +1901,9 @@ inline void SEL_ARG::make_root() left=right= &null_element; color=BLACK; next=prev=0; - use_count=0; elements=1; + use_count=0; + elements=1; + weight= 1 + (next_key_part? next_key_part->weight : 0); } SEL_ARG::SEL_ARG(Field *f,const uchar *min_value_arg, @@ -9853,12 +9855,14 @@ and_all_keys(RANGE_OPT_PARAM *param, SEL_ARG *key1, SEL_ARG *key2, return key2; key1->right= key1->left= &null_element; key1->next= key1->prev= 0; + key1->weight= 1 + (key1->next_key_part? key1->next_key_part->weight: 0); } for (next=key1->first(); next ; next=next->next) { if (next->next_key_part) { + uint old_weight= next->next_key_part->weight; SEL_ARG *tmp= key_and(param, next->next_key_part, key2, clone_flag); if (tmp && tmp->type == SEL_ARG::IMPOSSIBLE) { @@ -9866,21 +9870,22 @@ and_all_keys(RANGE_OPT_PARAM *param, SEL_ARG *key1, SEL_ARG *key2, continue; } next->next_key_part=tmp; + key1->weight+= (tmp? tmp->weight: 0) - old_weight; if (use_count) next->increment_use_count(use_count); if (param->alloced_sel_args > SEL_ARG::MAX_SEL_ARGS) break; } else + { next->next_key_part=key2; + key1->weight += key2->weight; + } } if (!key1) return &null_element; // Impossible ranges key1->use_count++; - /* Re-compute the result tree's weight. */ - key1->update_weight_locally(); - key1->max_part_no= MY_MAX(key2->max_part_no, key2->part+1); return key1; } @@ -10044,29 +10049,6 @@ get_range(SEL_ARG **e1,SEL_ARG **e2,SEL_ARG *root1) return 0; } -/* - @brief - Update the tree weight. - - @detail - Utility function to be called on a SEL_ARG tree root after doing local - modifications concerning changes at this key part. - Assumes that the weight of the graphs connected via next_key_part is - up to dayte. -*/ -void SEL_ARG::update_weight_locally() -{ - uint new_weight= 0; - const SEL_ARG *sl; - for (sl= first(); sl ; sl= sl->next) - { - new_weight++; - if (sl->next_key_part) - new_weight += sl->next_key_part->weight; - } - weight= new_weight; -} - #ifndef DBUG_OFF /* @@ -10826,9 +10808,6 @@ end: } key1->use_count++; - /* Re-compute the result tree's weight. */ - key1->update_weight_locally(); - key1->max_part_no= max_part_no; return key1; } @@ -16183,6 +16162,7 @@ const char *dbug_print_sel_arg(SEL_ARG *sel_arg) out.append(STRING_WITH_LEN("+inf")); else { + buf.length(0); print_sel_arg_key(sel_arg->field, sel_arg->max_value, &buf); out.append(buf); } |