diff options
author | Sergei Petrunia <sergey@mariadb.com> | 2023-02-02 17:12:39 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2023-02-15 16:28:08 +0100 |
commit | 2e6872791af2aab48490c24279ca3e24b64e377c (patch) | |
tree | 02284447c3e5ed7889d2d081495676b1efcc8a42 /sql | |
parent | d1a46c68cd4f6557cbb76de22cd6faee50e41725 (diff) | |
download | mariadb-git-2e6872791af2aab48490c24279ca3e24b64e377c.tar.gz |
MDEV-30218: Incorrect optimization for rowid_filtering, correction
Final corrections:
- Remove incorrect tracing, "rowid_filter_skipped"
- Put the worst_seeks sanity check back
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_select.cc | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 4bdfb659513..3f02d21ad0b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7961,10 +7961,20 @@ best_access_path(JOIN *join, type == JT_EQ_REF ? 0.5 * tmp : MY_MIN(tmp, keyread_tmp); double access_cost_factor= MY_MIN((tmp - key_access_cost) / rows, 1.0); - filter= - table->best_range_rowid_filter_for_partial_join(start_key->key, - rows, - access_cost_factor); + if (!(records < s->worst_seeks && + records <= thd->variables.max_seeks_for_key)) + { + // Don't use rowid filter + trace_access_idx.add("rowid_filter_skipped", "worst/max seeks clipping"); + filter= NULL; + } + else + { + filter= + table->best_range_rowid_filter_for_partial_join(start_key->key, + rows, + access_cost_factor); + } if (filter) { tmp-= filter->get_adjusted_gain(rows) - filter->get_cmp_gain(rows); @@ -8137,8 +8147,6 @@ best_access_path(JOIN *join, tmp-= filter->get_adjusted_gain(rows); DBUG_ASSERT(tmp >= 0); } - else - trace_access_scan.add("rowid_filter_skipped", "cost_factor <= 0"); type= JT_RANGE; } |