Commit ee753def authored by unknown's avatar unknown

MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs

This patch mainly adds sorting of all indexes for partial matching
according to their NULL selectivity. The patch also fixes a related bug
in subselect_rowid_merge_engine::test_null_row() where the wrong matched
indexes were skipped.

In addition the patch:
- adds few ::print() methods,
- renames few variables that had similar names but different purpose.
parent ae167403
This diff is collapsed.
......@@ -752,7 +752,7 @@ class Ordered_key
Index of the key in an array of keys. This index allows to
construct (sub)sets of keys represented by bitmaps.
*/
uint key_idx;
uint keyid;
/* The table being indexed. */
TABLE *tbl;
/* The columns being indexed. */
......@@ -810,7 +810,7 @@ class Ordered_key
public:
static void *operator new(size_t size) throw ()
{ return sql_alloc(size); }
Ordered_key(uint key_idx_arg, TABLE *tbl_arg,
Ordered_key(uint keyid_arg, TABLE *tbl_arg,
Item *search_key_arg, ha_rows null_count_arg,
ha_rows min_null_row_arg, ha_rows max_null_row_arg,
uchar *row_num_to_rowid_arg);
......@@ -822,7 +822,7 @@ class Ordered_key
bool init(int col_idx);
uint get_column_count() { return key_column_count; }
uint get_key_idx() { return key_idx; }
uint get_keyid() { return keyid; }
uint get_field_idx(uint i)
{
DBUG_ASSERT(i < key_column_count);
......@@ -841,8 +841,7 @@ class Ordered_key
}
void sort_keys();
double null_selectivity() { return (1 - null_count / null_key.n_bits); }
double null_selectivity();
/*
Position the current element at the first row that matches the key.
......@@ -896,6 +895,7 @@ class Ordered_key
return FALSE;
return bitmap_is_set(&null_key, row_num);
}
void print(String *str);
};
......@@ -957,10 +957,10 @@ class subselect_rowid_merge_engine: public subselect_engine
bool has_covering_null_row;
protected:
/*
Comparison function to compare keys in order of increasing bitmap
Comparison function to compare keys in order of decreasing bitmap
selectivity.
*/
static int cmp_keys_by_null_selectivity(Ordered_key *a, Ordered_key *b);
static int cmp_keys_by_null_selectivity(Ordered_key **k1, Ordered_key **k2);
/*
Comparison function used by the priority queue pq, the 'smaller' key
is the one with the smaller current row number.
......@@ -992,7 +992,7 @@ class subselect_rowid_merge_engine: public subselect_engine
uint8 uncacheable() { return UNCACHEABLE_DEPENDENT; }
void exclude() {}
table_map upper_select_const_tables() { return 0; }
void print(String*, enum_query_type) {}
void print(String*, enum_query_type);
bool change_result(Item_subselect*, select_result_interceptor*)
{ DBUG_ASSERT(FALSE); return false; }
bool no_tables() { return false; }
......
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