mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 03:17:20 +02:00
MDEV-38327 Minor optimizer comment cleanups and refactoring
factor out common index merge checks of quick select types
This commit is contained in:
parent
308ed52fb0
commit
6229192647
5 changed files with 24 additions and 28 deletions
|
|
@ -1307,6 +1307,13 @@ public:
|
|||
virtual void add_used_key_part_to_set()=0;
|
||||
};
|
||||
|
||||
inline bool is_index_merge(int qtype)
|
||||
{
|
||||
return qtype == QUICK_SELECT_I::QS_TYPE_INDEX_INTERSECT ||
|
||||
qtype == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE ||
|
||||
qtype == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT ||
|
||||
qtype == QUICK_SELECT_I::QS_TYPE_ROR_UNION;
|
||||
}
|
||||
|
||||
struct st_qsel_param;
|
||||
class PARAM;
|
||||
|
|
@ -1576,6 +1583,7 @@ public:
|
|||
|
||||
|
||||
|
||||
/* Index merge sort union */
|
||||
class QUICK_INDEX_MERGE_SELECT : public QUICK_INDEX_SORT_SELECT
|
||||
{
|
||||
private:
|
||||
|
|
@ -1593,6 +1601,7 @@ public:
|
|||
void add_keys_and_lengths(String *key_names, String *used_lengths) override;
|
||||
};
|
||||
|
||||
/* Index merge sort intersection */
|
||||
class QUICK_INDEX_INTERSECT_SELECT : public QUICK_INDEX_SORT_SELECT
|
||||
{
|
||||
protected:
|
||||
|
|
@ -1611,6 +1620,8 @@ public:
|
|||
|
||||
|
||||
/*
|
||||
Index merge intersection
|
||||
|
||||
Rowid-Ordered Retrieval (ROR) index intersection quick select.
|
||||
This quick select produces intersection of row sequences returned
|
||||
by several QUICK_RANGE_SELECTs it "merges".
|
||||
|
|
@ -1698,6 +1709,8 @@ public:
|
|||
|
||||
|
||||
/*
|
||||
Index merge union
|
||||
|
||||
Rowid-Ordered Retrieval index union select.
|
||||
This quick select produces union of row sequences returned by several
|
||||
quick select it "merges".
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@
|
|||
5. At the execution stage
|
||||
In the function sub_select() just before the first access of a join
|
||||
table s employing a range filter
|
||||
The method JOIN_TAB::build_range_rowid_filter_if_needed() is called
|
||||
The method JOIN_TAB::build_range_rowid_filter() is called
|
||||
The method fills the filter using the quick select created by
|
||||
JOIN::make_range_rowid_filters().
|
||||
|
||||
|
|
|
|||
|
|
@ -159,11 +159,7 @@ bool Update_plan::save_explain_data_intern(THD *thd,
|
|||
/* Set jtype */
|
||||
if (select && select->quick)
|
||||
{
|
||||
int quick_type= select->quick->get_type();
|
||||
if ((quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE) ||
|
||||
(quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_INTERSECT) ||
|
||||
(quick_type == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT) ||
|
||||
(quick_type == QUICK_SELECT_I::QS_TYPE_ROR_UNION))
|
||||
if (is_index_merge(select->quick->get_type()))
|
||||
explain->jtype= JT_INDEX_MERGE;
|
||||
else
|
||||
explain->jtype= JT_RANGE;
|
||||
|
|
|
|||
|
|
@ -27404,17 +27404,13 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
|
|||
}
|
||||
else if (select && select->quick) // Range found by opt_range
|
||||
{
|
||||
int quick_type= select->quick->get_type();
|
||||
/*
|
||||
assume results are not ordered when index merge is used
|
||||
TODO: sergeyp: Results of all index merge selects actually are ordered
|
||||
/*
|
||||
assume results are not ordered when index merge is used
|
||||
TODO: sergeyp: Results of all index merge selects actually are ordered
|
||||
by clustered PK values.
|
||||
*/
|
||||
|
||||
if (quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE ||
|
||||
quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_INTERSECT ||
|
||||
quick_type == QUICK_SELECT_I::QS_TYPE_ROR_UNION ||
|
||||
quick_type == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT)
|
||||
|
||||
if (is_index_merge(select->quick->get_type()))
|
||||
{
|
||||
/*
|
||||
we set ref_key=MAX_KEY instead of -1, because test_if_cheaper_ordering()
|
||||
|
|
@ -27654,10 +27650,7 @@ check_reverse_order:
|
|||
goto skipped_filesort;
|
||||
|
||||
quick_type= select->quick->get_type();
|
||||
if (quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE ||
|
||||
quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_INTERSECT ||
|
||||
quick_type == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT ||
|
||||
quick_type == QUICK_SELECT_I::QS_TYPE_ROR_UNION ||
|
||||
if (is_index_merge(quick_type) ||
|
||||
quick_type == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)
|
||||
{
|
||||
tab->limit= 0;
|
||||
|
|
@ -30850,10 +30843,7 @@ bool JOIN_TAB::save_explain_data(Explain_table_access *eta,
|
|||
{
|
||||
cur_quick= tab_select->quick;
|
||||
quick_type= cur_quick->get_type();
|
||||
if ((quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE) ||
|
||||
(quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_INTERSECT) ||
|
||||
(quick_type == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT) ||
|
||||
(quick_type == QUICK_SELECT_I::QS_TYPE_ROR_UNION))
|
||||
if (is_index_merge(quick_type))
|
||||
tab_type= type == JT_HASH ? JT_HASH_INDEX_MERGE : JT_INDEX_MERGE;
|
||||
else
|
||||
tab_type= type == JT_HASH ? JT_HASH_RANGE : JT_RANGE;
|
||||
|
|
@ -31055,10 +31045,7 @@ bool JOIN_TAB::save_explain_data(Explain_table_access *eta,
|
|||
eta->pushed_index_cond= cache_idx_cond;
|
||||
}
|
||||
|
||||
if (quick_type == QUICK_SELECT_I::QS_TYPE_ROR_UNION ||
|
||||
quick_type == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT ||
|
||||
quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_INTERSECT ||
|
||||
quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE)
|
||||
if (is_index_merge(quick_type))
|
||||
{
|
||||
eta->push_extra(ET_USING);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4034,7 +4034,7 @@ row_search_idx_cond_check(
|
|||
byte* mysql_rec, /*!< out: record
|
||||
in MySQL format (invalid unless
|
||||
prebuilt->idx_cond!=NULL and
|
||||
we return ICP_MATCH) */
|
||||
we return CHECK_POS) */
|
||||
row_prebuilt_t* prebuilt, /*!< in/out: prebuilt struct
|
||||
for the table handle */
|
||||
const rec_t* rec, /*!< in: InnoDB record */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue