diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2009-12-15 20:23:55 +0300 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2009-12-15 20:23:55 +0300 |
commit | 59b64720102f8f4f43c856f1e9c2ba2007156b18 (patch) | |
tree | 16ea30fc86361b17dd05766e4aaf9b4b12275c09 /sql | |
parent | 2a496c4dcfaa715588fa48009b7779d38b1a137a (diff) | |
download | mariadb-git-59b64720102f8f4f43c856f1e9c2ba2007156b18.tar.gz |
Backport into MariaDB-5.2 the following:
WL#2474 "Multi Range Read: Change the default MRR implementation to implement new MRR interface"
WL#2475 "Batched range read functions for MyISAM/InnoDb"
"Index condition pushdown for MyISAM/InnoDB"
- Adjust test results (checked)
- Code cleanup.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ds_mrr.cc | 16 | ||||
-rw-r--r-- | sql/ds_mrr.h | 7 | ||||
-rw-r--r-- | sql/ha_ndbcluster.cc | 3 | ||||
-rw-r--r-- | sql/ha_ndbcluster.h | 10 | ||||
-rw-r--r-- | sql/handler.cc | 130 | ||||
-rw-r--r-- | sql/handler.h | 18 | ||||
-rw-r--r-- | sql/sql_select.cc | 7 | ||||
-rw-r--r-- | sql/sql_select.h | 3 |
8 files changed, 35 insertions, 159 deletions
diff --git a/sql/ds_mrr.cc b/sql/ds_mrr.cc index 7a0fc65b8f5..0bf63e95a1f 100644 --- a/sql/ds_mrr.cc +++ b/sql/ds_mrr.cc @@ -950,8 +950,15 @@ void push_index_cond(JOIN_TAB *tab, uint keyno, bool other_tbls_ok) ((tab->table->file->index_flags(keyno, 0, 1) & HA_DO_INDEX_COND_PUSHDOWN) && tab->join->thd->variables.engine_condition_pushdown); - // psergey: - // + + /* + Do not try index condition pushdown on indexes which have partially-covered + columns. Unpacking from a column prefix into index tuple is not a supported + operation in some engines, see e.g. MySQL BUG#42991. + TODO: a better solution would be not to consider partially-covered columns + as parts of the index and still produce/check index condition for + fully-covered index columns. + */ KEY *key_info= tab->table->key_info + keyno; for (uint kp= 0; kp < key_info->key_parts; kp++) { @@ -961,7 +968,7 @@ void push_index_cond(JOIN_TAB *tab, uint keyno, bool other_tbls_ok) break; } } - // :psergey + /* When WL#5116 is done this DBUG statement must be removed. It's just a temporary hack to allow us to discriminate whether a test failure relates @@ -984,7 +991,8 @@ void push_index_cond(JOIN_TAB *tab, uint keyno, bool other_tbls_ok) Item *idx_remainder_cond= 0; tab->pre_idx_push_select_cond= tab->select_cond; #if 0 - // The following is only needed for BKA: + /* + psergey: enable the below when we backport BKA: */ /* For BKA cache we store condition to special BKA cache field because evaluation of the condition requires additional operations diff --git a/sql/ds_mrr.h b/sql/ds_mrr.h index 02abe72a4c1..12e2c955f0a 100644 --- a/sql/ds_mrr.h +++ b/sql/ds_mrr.h @@ -1,4 +1,8 @@ - +/* + This file contains declarations for + - Disk-Sweep MultiRangeRead (DS-MRR) implementation + - Index Condition Pushdown helper functions +*/ /** A Disk-Sweep MRR interface implementation @@ -65,4 +69,5 @@ private: uint *buffer_size, COST_VECT *cost); }; +void push_index_cond(JOIN_TAB *tab, uint keyno, bool other_tbls_ok); diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index c6b48c5b744..edfec934b2a 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -8702,6 +8702,8 @@ ha_ndbcluster::null_value_index_search(KEY_MULTI_RANGE *ranges, DBUG_RETURN(FALSE); } +#if 0 +/* MRR/NDB is disabled, for details see method declarations in ha_ndbcluster.h */ int ha_ndbcluster::read_multi_range_first(KEY_MULTI_RANGE **found_range_p, KEY_MULTI_RANGE *ranges, @@ -9074,6 +9076,7 @@ found_next: m_multi_range_result_ptr += reclength; DBUG_RETURN(0); } +#endif int ha_ndbcluster::setup_recattr(const NdbRecAttr* curr) diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index f3651ebeca9..9e6d697492a 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -259,10 +259,20 @@ class ha_ndbcluster: public handler /** * Multi range stuff */ +#if 0 + /* + MRR/NDB is disabled in MariaDB. This is because in MariaDB, we've + backported + - the latest version of MRR interface (BKA needs this) + - the latest version of DS-MRR implementation + but didn't backport the latest version MRR/NDB implementation. + + */ int read_multi_range_first(KEY_MULTI_RANGE **found_range_p, KEY_MULTI_RANGE*ranges, uint range_count, bool sorted, HANDLER_BUFFER *buffer); int read_multi_range_next(KEY_MULTI_RANGE **found_range_p); +#endif bool null_value_index_search(KEY_MULTI_RANGE *ranges, KEY_MULTI_RANGE *end_range, HANDLER_BUFFER *buffer); diff --git a/sql/handler.cc b/sql/handler.cc index 3f4fec8f23a..fe3639a0e00 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4193,136 +4193,6 @@ double handler::index_only_read_time(uint keynr, double records) return read_time; } -#if 0 -// psergey-mrr - -/** - Read the first row of a multi-range set. - - @param found_range_p Returns a pointer to the element in 'ranges' that - corresponds to the returned row. - @param ranges An array of KEY_MULTI_RANGE range descriptions. - @param range_count Number of ranges in 'ranges'. - @param sorted If result should be sorted per key. - @param buffer A HANDLER_BUFFER for internal handler usage. - - @note - - Record is read into table->record[0]. - - *found_range_p returns a valid value only if read_multi_range_first() - returns 0. - - Sorting is done within each range. If you want an overall sort, enter - 'ranges' with sorted ranges. - - @retval - 0 OK, found a row - @retval - HA_ERR_END_OF_FILE No rows in range - @retval - \# Error code -*/ -int handler::read_multi_range_first(KEY_MULTI_RANGE **found_range_p, - KEY_MULTI_RANGE *ranges, uint range_count, - bool sorted, HANDLER_BUFFER *buffer) -{ - int result= HA_ERR_END_OF_FILE; - DBUG_ENTER("handler::read_multi_range_first"); - multi_range_sorted= sorted; - multi_range_buffer= buffer; - - table->mark_columns_used_by_index_no_reset(active_index, table->read_set); - table->column_bitmaps_set(table->read_set, table->write_set); - - for (multi_range_curr= ranges, multi_range_end= ranges + range_count; - multi_range_curr < multi_range_end; - multi_range_curr++) - { - result= read_range_first(multi_range_curr->start_key.keypart_map ? - &multi_range_curr->start_key : 0, - multi_range_curr->end_key.keypart_map ? - &multi_range_curr->end_key : 0, - test(multi_range_curr->range_flag & EQ_RANGE), - multi_range_sorted); - if (result != HA_ERR_END_OF_FILE) - break; - } - - *found_range_p= multi_range_curr; - DBUG_PRINT("exit",("result %d", result)); - DBUG_RETURN(result); -} - - -/** - Read the next row of a multi-range set. - - @param found_range_p Returns a pointer to the element in 'ranges' that - corresponds to the returned row. - - @note - - Record is read into table->record[0]. - - *found_range_p returns a valid value only if read_multi_range_next() - returns 0. - - @retval - 0 OK, found a row - @retval - HA_ERR_END_OF_FILE No (more) rows in range - @retval - \# Error code -*/ -int handler::read_multi_range_next(KEY_MULTI_RANGE **found_range_p) -{ - int result; - DBUG_ENTER("handler::read_multi_range_next"); - - /* We should not be called after the last call returned EOF. */ - DBUG_ASSERT(multi_range_curr < multi_range_end); - - do - { - /* Save a call if there can be only one row in range. */ - if (multi_range_curr->range_flag != (UNIQUE_RANGE | EQ_RANGE)) - { - result= read_range_next(); - - /* On success or non-EOF errors jump to the end. */ - if (result != HA_ERR_END_OF_FILE) - break; - } - else - { - if (was_semi_consistent_read()) - goto scan_it_again; - /* - We need to set this for the last range only, but checking this - condition is more expensive than just setting the result code. - */ - result= HA_ERR_END_OF_FILE; - } - - multi_range_curr++; -scan_it_again: - /* Try the next range(s) until one matches a record. */ - for (; multi_range_curr < multi_range_end; multi_range_curr++) - { - result= read_range_first(multi_range_curr->start_key.keypart_map ? - &multi_range_curr->start_key : 0, - multi_range_curr->end_key.keypart_map ? - &multi_range_curr->end_key : 0, - test(multi_range_curr->range_flag & EQ_RANGE), - multi_range_sorted); - if (result != HA_ERR_END_OF_FILE) - break; - } - } - while ((result == HA_ERR_END_OF_FILE) && - (multi_range_curr < multi_range_end)); - - *found_range_p= multi_range_curr; - DBUG_PRINT("exit",("handler::read_multi_range_next: result %d", result)); - DBUG_RETURN(result); -} -#endif /** Read first row between two ranges. diff --git a/sql/handler.h b/sql/handler.h index 2ad7d61b03b..ed7426b0811 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1290,15 +1290,6 @@ public: ha_statistics stats; - /** The following are for read_multi_range */ -//////psergey: was: -#if 0 - bool multi_range_sorted; - KEY_MULTI_RANGE *multi_range_curr; - KEY_MULTI_RANGE *multi_range_end; - HANDLER_BUFFER *multi_range_buffer; -#endif -//////psergey /** MultiRangeRead-related members: */ range_seq_t mrr_iter; /* Interator to traverse the range sequence */ RANGE_SEQ_IF mrr_funcs; /* Range sequence traversal functions */ @@ -1311,7 +1302,6 @@ public: bool mrr_have_range; /** Current range (the one we're now returning rows from) */ KEY_MULTI_RANGE mrr_cur_range; -//////psergey /** The following are for read_range() */ key_range save_end_range, *end_range; @@ -1744,13 +1734,6 @@ public: update_index_statistics(); return error; } -#if 0 - virtual int read_multi_range_first(KEY_MULTI_RANGE **found_range_p, - KEY_MULTI_RANGE *ranges, uint range_count, - bool sorted, HANDLER_BUFFER *buffer); - virtual int read_multi_range_next(KEY_MULTI_RANGE **found_range_p); -#endif - //psergey-mrr: virtual ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, void *seq_init_param, uint n_ranges, uint *bufsz, @@ -1761,7 +1744,6 @@ public: uint n_ranges, uint mode, HANDLER_BUFFER *buf); virtual int multi_range_read_next(char **range_info); - //psergey-mrr: ends virtual int read_range_first(const key_range *start_key, const key_range *end_key, bool eq_range, bool sorted); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 434afe8fd69..4ea391cbfa0 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -16734,11 +16734,12 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, if (keyno != MAX_KEY && keyno == table->file->pushed_idx_cond_keyno && table->file->pushed_idx_cond) extra.append(STRING_WITH_LEN("; Using index condition")); - /** - psergey-mrr: + /* + psergey: enable the below when we backport BKA: + else if (tab->cache_idx_cond) extra.append(STRING_WITH_LEN("; Using index condition(BKA)")); - **/ + */ 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_MERGE) diff --git a/sql/sql_select.h b/sql/sql_select.h index 0a6702a8135..4945d433fac 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -780,7 +780,4 @@ inline bool optimizer_flag(THD *thd, uint flag) void eliminate_tables(JOIN *join); -/// psergey-mrr: -void push_index_cond(JOIN_TAB *tab, uint keyno, bool other_tbls_ok); - |