mirror of
https://github.com/MariaDB/server.git
synced 2025-09-02 09:41:40 +03:00
Added page_range to records_in_range() to improve range statistics
Prototype change: - virtual ha_rows records_in_range(uint inx, key_range *min_key, - key_range *max_key) + virtual ha_rows records_in_range(uint inx, const key_range *min_key, + const key_range *max_key, + page_range *res) The handler can ignore the page_range parameter. In the case the handler updates the parameter, the optimizer can deduce the following: - If previous range's last key is on the same block as next range's first key - If the current key range is in one block - We can also assume that the first and last block read are cached! This can be used for a better calculation of IO seeks when we estimate the cost of a range index scan. The parameter is fully implemented for MyISAM, Aria and InnoDB. A separate patch will update handler::multi_range_read_info_const() to take the benefits of this change and also remove the double records_in_range() calls that are not anymore needed.
This commit is contained in:
@@ -93,9 +93,8 @@ public:
|
||||
int index_prev(uchar *buf);
|
||||
int index_first(uchar *buf);
|
||||
int index_last(uchar *buf);
|
||||
ha_rows records_in_range(uint inx, key_range *min_key,
|
||||
key_range *max_key);
|
||||
|
||||
ha_rows records_in_range(uint inx, const key_range *start_key,
|
||||
const key_range *end_key, page_range *pages);
|
||||
double scan_time() { return (double)nvalues(); }
|
||||
double read_time(uint index, uint ranges, ha_rows rows) { return (double)rows; }
|
||||
double keyread_time(uint index, uint ranges, ha_rows rows) { return (double)rows; }
|
||||
@@ -234,8 +233,9 @@ int ha_seq::index_last(uchar *buf)
|
||||
return index_prev(buf);
|
||||
}
|
||||
|
||||
ha_rows ha_seq::records_in_range(uint inx, key_range *min_key,
|
||||
key_range *max_key)
|
||||
ha_rows ha_seq::records_in_range(uint inx, const key_range *min_key,
|
||||
const key_range *max_key,
|
||||
page_range *pages)
|
||||
{
|
||||
ulonglong kmin= min_key ? uint8korr(min_key->key) : seqs->from;
|
||||
ulonglong kmax= max_key ? uint8korr(max_key->key) : seqs->to - 1;
|
||||
|
Reference in New Issue
Block a user