summaryrefslogtreecommitdiff
path: root/sql/opt_range.h
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2018-08-17 14:27:42 -0700
committerIgor Babaev <igor@askmonty.org>2018-08-17 14:28:39 -0700
commit4eac5df3fcebb1adf52e33d9d88dc05bc1e339ce (patch)
tree9920b683a5ac5928d271b9e679e74c7937924922 /sql/opt_range.h
parentd6f7fd601637a070ccf922073c0ef9a41a129717 (diff)
downloadmariadb-git-4eac5df3fcebb1adf52e33d9d88dc05bc1e339ce.tar.gz
MDEV-16934 Query with very large IN clause lists runs slowly
This patch introduces support for the system variable eq_range_index_dive_limit that existed in MySQL starting from 5.6. The variable sets a limit for index dives into equality ranges. Index dives are performed by optimizer to estimate the number of rows in range scans. Index dives usually provide good estimate but they are pretty expensive. To estimate the number of rows in equality ranges statistical data on indexes can be employed. Its usage gives not so good estimates but it's cheap. So if the number of equality dives required by an index scan exceeds the set limit no dives for equality ranges are performed by the optimizer for this index. As the new system variable is introduced in a stable version the default value for it is set to a special value meaning there is no limit for the number of index dives performed by the optimizer. The patch partially uses the MySQL code for WL 5957 'Statistics-based Range optimization for many ranges'.
Diffstat (limited to 'sql/opt_range.h')
-rw-r--r--sql/opt_range.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/sql/opt_range.h b/sql/opt_range.h
index c1f7079ce7f..6698c987e78 100644
--- a/sql/opt_range.h
+++ b/sql/opt_range.h
@@ -242,7 +242,7 @@ public:
Number of children of this element in the RB-tree, plus 1 for this
element itself.
*/
- uint16 elements;
+ uint32 elements;
/*
Valid only for elements which are RB-tree roots: Number of times this
RB-tree is referred to (it is referred by SEL_ARG::next_key_part or by
@@ -1664,6 +1664,8 @@ SQL_SELECT *make_select(TABLE *head, table_map const_tables,
bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond);
+bool eq_ranges_exceeds_limit(RANGE_SEQ_IF *seq, void *seq_init_param);
+
#ifdef WITH_PARTITION_STORAGE_ENGINE
bool prune_partitions(THD *thd, TABLE *table, Item *pprune_cond);
#endif