Commit e0999cdf authored by Sergey Petrunya's avatar Sergey Petrunya

DS-MRR support improvements (MWL#123, MWL#124, MWL#125)

- Lots of TODO comments
- add mrr_sort_keys flag to @@optimizer_switch
- [from Igor] SQL layer part passes HA_MRR_MATERIALIZED_KEYS flag
- Don't call rnd_pos() many times in a row if sorted rowid buffer
  has the same rowid value for multiple consequive (rowid, range_id) pairs.
parent e1006e9e
This diff is collapsed.
......@@ -1322,6 +1322,12 @@ void get_sweep_read_cost(TABLE *table, ha_rows nrows, bool interrupted,
*/
#define HA_MRR_NO_NULL_ENDPOINTS 128
/*
The MRR user has materialized range keys somewhere in the user's buffer.
This can be used for optimization of the procedure that sorts these keys
since in this case key values don't have to be copied into the MRR buffer.
*/
#define HA_MRR_MATERIALIZED_KEYS 256
/*
......
This diff is collapsed.
......@@ -114,6 +114,8 @@ private:
uchar *mrr_buf_last; /* When reading: end of used buffer space */
uchar *mrr_buf_end; /* End of the buffer */
uchar *mrr_buf_next_identical;
bool dsmrr_eof; /* TRUE <=> We have reached EOF when reading index tuples */
/* TRUE <=> need range association, buffer holds {rowid, range_id} pairs */
......@@ -143,8 +145,8 @@ private:
uint *buffer_size, COST_VECT *cost);
bool check_cpk_scan(uint keyno, uint mrr_flags);
static int key_tuple_cmp(void* arg, uchar* key1, uchar* key2);
int dsmrr_fill_buffer();
void dsmrr_fill_buffer_cpk();
int dsmrr_fill_rowid_buffer();
void dsmrr_fill_key_buffer();
int dsmrr_next_cpk(char **range_info);
};
......@@ -571,12 +571,13 @@ protected:
#define OPTIMIZER_SWITCH_PARTIAL_MATCH_ROWID_MERGE 512
#define OPTIMIZER_SWITCH_PARTIAL_MATCH_TABLE_SCAN 1024
#define OPTIMIZER_SWITCH_SUBQUERY_CACHE (1<<11)
#define OPTIMIZER_SWITCH_MRR_SORT_KEYS (1<<12)
#ifdef DBUG_OFF
# define OPTIMIZER_SWITCH_LAST (1<<12)
#else
# define OPTIMIZER_SWITCH_TABLE_ELIMINATION (1<<12)
# define OPTIMIZER_SWITCH_LAST (1<<13)
#else
# define OPTIMIZER_SWITCH_TABLE_ELIMINATION (1<<13)
# define OPTIMIZER_SWITCH_LAST (1<<14)
#endif
#ifdef DBUG_OFF
......@@ -592,7 +593,8 @@ protected:
OPTIMIZER_SWITCH_SEMIJOIN | \
OPTIMIZER_SWITCH_PARTIAL_MATCH_ROWID_MERGE|\
OPTIMIZER_SWITCH_PARTIAL_MATCH_TABLE_SCAN|\
OPTIMIZER_SWITCH_SUBQUERY_CACHE)
OPTIMIZER_SWITCH_SUBQUERY_CACHE|\
OPTIMIZER_SWITCH_MRR_SORT_KEYS)
#else
# define OPTIMIZER_SWITCH_DEFAULT (OPTIMIZER_SWITCH_INDEX_MERGE | \
OPTIMIZER_SWITCH_INDEX_MERGE_UNION | \
......@@ -606,7 +608,8 @@ protected:
OPTIMIZER_SWITCH_SEMIJOIN | \
OPTIMIZER_SWITCH_PARTIAL_MATCH_ROWID_MERGE|\
OPTIMIZER_SWITCH_PARTIAL_MATCH_TABLE_SCAN|\
OPTIMIZER_SWITCH_SUBQUERY_CACHE)
OPTIMIZER_SWITCH_SUBQUERY_CACHE|\
OPTIMIZER_SWITCH_MRR_SORT_KEYS)
#endif
/*
......
......@@ -308,6 +308,7 @@ static const char *optimizer_switch_names[]=
"partial_match_rowid_merge",
"partial_match_table_scan",
"subquery_cache",
"mrr_sort_keys",
#ifndef DBUG_OFF
"table_elimination",
#endif
......@@ -329,6 +330,7 @@ static const unsigned int optimizer_switch_names_len[]=
sizeof("partial_match_rowid_merge") - 1,
sizeof("partial_match_table_scan") - 1,
sizeof("subquery_cache") - 1,
sizeof("mrr_sort_keys") - 1,
#ifndef DBUG_OFF
sizeof("table_elimination") - 1,
#endif
......@@ -415,7 +417,8 @@ static const char *optimizer_switch_str="index_merge=on,index_merge_union=on,"
"semijoin=on,"
"partial_match_rowid_merge=on,"
"partial_match_table_scan=on,"
"subquery_cache=on"
"subquery_cache=on,"
"mrr_sort_keys=on"
#ifndef DBUG_OFF
",table_elimination=on";
#else
......
......@@ -651,6 +651,9 @@ int JOIN_CACHE_BKA::init()
use_emb_key= check_emb_key_usage();
if (use_emb_key)
mrr_mode|= HA_MRR_MATERIALIZED_KEYS;
create_remaining_fields(FALSE);
set_constants();
......@@ -2631,6 +2634,8 @@ int JOIN_CACHE_BKA_UNIQUE::init()
data_fields_offset+= copy->length;
}
mrr_mode|= HA_MRR_MATERIALIZED_KEYS;
DBUG_RETURN(rc);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment