1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

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"
Igor's fix from sp1r-igor@olga.mysql.com-20080330055902-07614:
  There could be observed the following problems:
  1. EXPLAIN did not mention pushdown conditions from on expressions in the 
  'extra' column.  As a result if a query had no where conditions pushed 
  down to a table, but had on conditions pushed to this table the 'extra' 
  column in the EXPLAIN for the table missed 'using where'.
  2. Conditions for ref access were not eliminated from on expressions 
  though such conditions were eliminated from the where condition.
This commit is contained in:
Sergey Petrunya
2009-12-15 10:16:46 +03:00
parent e4e1ae0d13
commit 96e092dc73
136 changed files with 18754 additions and 1169 deletions

View File

@@ -4161,6 +4161,41 @@ void ha_binlog_log_query(THD *thd, handlerton *hton,
}
#endif
/**
Calculate cost of 'index only' scan for given index and number of records
@param keynr Index number
@param records Estimated number of records to be retrieved
@note
It is assumed that we will read trough the whole key range and that all
key blocks are half full (normally things are much better). It is also
assumed that each time we read the next key from the index, the handler
performs a random seek, thus the cost is proportional to the number of
blocks read.
@todo
Consider joining this function and handler::read_time() into one
handler::read_time(keynr, records, ranges, bool index_only) function.
@return
Estimated cost of 'index only' scan
*/
double handler::index_only_read_time(uint keynr, double records)
{
double read_time;
uint keys_per_block= (stats.block_size/2/
(table->key_info[keynr].key_length + ref_length) + 1);
read_time=((double) (records + keys_per_block-1) /
(double) keys_per_block);
return read_time;
}
#if 0
// psergey-mrr
/**
Read the first row of a multi-range set.
@@ -4287,7 +4322,7 @@ scan_it_again:
DBUG_PRINT("exit",("handler::read_multi_range_next: result %d", result));
DBUG_RETURN(result);
}
#endif
/**
Read first row between two ranges.
@@ -4391,7 +4426,7 @@ int handler::read_range_next()
int handler::compare_key(key_range *range)
{
int cmp;
if (!range)
if (!range || in_range_check_pushed_down)
return 0; // No max range
cmp= key_cmp(range_key_part, range->key, range->length);
if (!cmp)
@@ -4400,6 +4435,23 @@ int handler::compare_key(key_range *range)
}
/*
Same as compare_key() but doesn't check have in_range_check_pushed_down.
This is used by index condition pushdown implementation.
*/
int handler::compare_key2(key_range *range)
{
int cmp;
if (!range)
return 0; // no max range
cmp= key_cmp(range_key_part, range->key, range->length);
if (!cmp)
cmp= key_compare_result_on_equal;
return cmp;
}
int handler::index_read_idx_map(uchar * buf, uint index, const uchar * key,
key_part_map keypart_map,
enum ha_rkey_function find_flag)