summaryrefslogtreecommitdiff
path: root/sql/table.h
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2019-02-03 14:56:12 -0800
committerIgor Babaev <igor@askmonty.org>2019-02-03 14:56:12 -0800
commit658128af43b4d7c6db445164f8ed25ed4d1e3109 (patch)
tree7a71580cca55759b8bb2730e117436478948d77f /sql/table.h
parent5f46670bd09babbee75a24ac82eb4ade0706da66 (diff)
downloadmariadb-git-658128af43b4d7c6db445164f8ed25ed4d1e3109.tar.gz
MDEV-16188 Use in-memory PK filters built from range index scans
This patch contains a full implementation of the optimization that allows to use in-memory rowid / primary filters built for range   conditions over indexes. In many cases usage of such filters reduce   the number of disk seeks spent for fetching table rows. In this implementation the choice of what possible filter to be applied   (if any) is made purely on cost-based considerations. This implementation re-achitectured the partial implementation of the feature pushed by Galina Shalygina in the commit 8d5a11122c32f4d9eb87536886c6e893377bdd07. Besides this patch contains a better implementation of the generic   handler function handler::multi_range_read_info_const() that takes into account gaps between ranges when calculating the cost of range index scans. It also contains some corrections of the implementation of the handler function records_in_range() for MyISAM. This patch supports the feature for InnoDB and MyISAM.
Diffstat (limited to 'sql/table.h')
-rw-r--r--sql/table.h42
1 files changed, 24 insertions, 18 deletions
diff --git a/sql/table.h b/sql/table.h
index 3c782c34bc3..1b8b837c35b 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -55,7 +55,7 @@ class Virtual_column_info;
class Table_triggers_list;
class TMP_TABLE_PARAM;
class SEQUENCE;
-class Range_filter_cost_info;
+class Range_rowid_filter_cost_info;
/*
Used to identify NESTED_JOIN structures within a join (applicable only to
@@ -1002,6 +1002,8 @@ struct TABLE_SHARE
/* frees the memory allocated in read_frm_image */
void free_frm_image(const uchar *frm);
+
+ void set_overlapped_keys();
};
@@ -1193,7 +1195,14 @@ public:
and max #key parts that range access would use.
*/
ha_rows quick_rows[MAX_KEY];
+ uint quick_key_parts[MAX_KEY];
+
double quick_costs[MAX_KEY];
+ /*
+ If there is a range access by i-th index then the cost of
+ index only access for it is stored in quick_index_only_costs[i]
+ */
+ double quick_index_only_costs[MAX_KEY];
/*
Bitmaps of key parts that =const for the duration of join execution. If
@@ -1202,10 +1211,7 @@ public:
*/
key_part_map const_key_parts[MAX_KEY];
- uint quick_key_parts[MAX_KEY];
uint quick_n_ranges[MAX_KEY];
- /* For each key I/O access cost is stored */
- double quick_key_io[MAX_KEY];
/*
Estimate of number of records that satisfy SARGable part of the table
@@ -1497,21 +1503,21 @@ public:
double get_materialization_cost(); // Now used only if is_splittable()==true
void add_splitting_info_for_key_field(struct KEY_FIELD *key_field);
+ key_map with_impossible_ranges;
+
+ /* Number of cost info elements for possible range filters */
+ uint range_rowid_filter_cost_info_elems;
+ /* Pointer to the array of cost info elements for range filters */
+ Range_rowid_filter_cost_info *range_rowid_filter_cost_info;
+ /* The array of pointers to cost info elements for range filters */
+ Range_rowid_filter_cost_info **range_rowid_filter_cost_info_ptr;
+
+ void init_cost_info_for_usable_range_rowid_filters(THD *thd);
+ void prune_range_rowid_filters();
+ Range_rowid_filter_cost_info *
+ best_range_rowid_filter_for_partial_join(uint access_key_no,
+ double records);
- /**
- Range filter info
- */
- /* Minimum possible #T value to apply filter*/
- uint best_filter_count;
- uint range_filter_cost_info_elements;
- Range_filter_cost_info *range_filter_cost_info;
- Range_filter_cost_info
- *best_filter_for_current_join_order(uint ref_key_no,
- double record_count,
- double records);
- void sort_range_filter_cost_info_array();
- void prune_range_filters();
- void select_usable_range_filters(THD *thd);
/**
System Versioning support
*/