diff options
author | Igor Babaev <igor@askmonty.org> | 2022-10-25 18:07:27 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2022-10-25 18:07:27 -0700 |
commit | eee0fda325fcf353ea863c87a46ff2995eb1711f (patch) | |
tree | 6117cd851fd12973e5fddfe6acc42056e9722317 /sql/sql_analyze_stmt.h | |
parent | 42802ad66c49b6de11b37c7ea4e4658ccc5a94aa (diff) | |
download | mariadb-git-bb-10.5-MDEV-28846.tar.gz |
MDEV-28846 Poor performance when rowid filter contains no elementsbb-10.5-MDEV-28846
When a range rowid filter was used with an index ref access the cost of
accessing the index entries for the records rejected by the filter was not
taken into account. For a ref access by an index with big average number
of records per key this led to poor execution plans if selectivity of the
used filter was high.
The patch resolves this problem. It also introduces a minor optimization
that skips look-ups into a filter that turns out to be empty.
With this patch the output of ANALYZE stmt reports the number of look-ups
into used rowid filters.
The test cases that were supposed to use rowid filters have been adjusted
in order to use similar execution plans after this fix.
This patch prepared for 10.5 differs from the patch resolving the problem
for 10.4 because he code that calculates the cost of index only access has
been changed for 10.5 making usage of rowid filters more favorable.
Approved by Oleksandr Byelkin <sanja@mariadb.com>
Diffstat (limited to 'sql/sql_analyze_stmt.h')
-rw-r--r-- | sql/sql_analyze_stmt.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sql/sql_analyze_stmt.h b/sql/sql_analyze_stmt.h index 990c79fb9ad..968b8d38295 100644 --- a/sql/sql_analyze_stmt.h +++ b/sql/sql_analyze_stmt.h @@ -416,12 +416,13 @@ public: uint get_container_elements() const { return container_elements; } + uint get_container_lookups() { return n_checks; } + double get_r_selectivity_pct() const { - return static_cast<double>(n_positive_checks) / - static_cast<double>(n_checks); + return n_checks ? static_cast<double>(n_positive_checks) / + static_cast<double>(n_checks) : 0; } size_t get_container_buff_size() const { return container_buff_size; } }; - |