diff options
author | Monty <monty@mariadb.org> | 2020-02-27 19:12:27 +0200 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2020-03-27 03:54:45 +0200 |
commit | f36ca142f7fa59598e34e842b60372b963067766 (patch) | |
tree | 4b797dcf88e98fd9fe83e3a29bfaabc10b7219c2 /storage/mroonga | |
parent | 9b061990801b5c8309149794145f9c361bb8cfc6 (diff) | |
download | mariadb-git-f36ca142f7fa59598e34e842b60372b963067766.tar.gz |
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.
Diffstat (limited to 'storage/mroonga')
-rw-r--r-- | storage/mroonga/ha_mroonga.cpp | 27 | ||||
-rw-r--r-- | storage/mroonga/ha_mroonga.hpp | 17 |
2 files changed, 27 insertions, 17 deletions
diff --git a/storage/mroonga/ha_mroonga.cpp b/storage/mroonga/ha_mroonga.cpp index 49208fc51bb..728fd8acd7c 100644 --- a/storage/mroonga/ha_mroonga.cpp +++ b/storage/mroonga/ha_mroonga.cpp @@ -7437,8 +7437,10 @@ uint ha_mroonga::max_supported_key_parts() const DBUG_RETURN(parts); } -ha_rows ha_mroonga::wrapper_records_in_range(uint key_nr, key_range *range_min, - key_range *range_max) +ha_rows ha_mroonga::wrapper_records_in_range(uint key_nr, + const key_range *range_min, + const key_range *range_max, + page_range *pages) { ha_rows row_count; MRN_DBUG_ENTER_METHOD(); @@ -7448,15 +7450,18 @@ ha_rows ha_mroonga::wrapper_records_in_range(uint key_nr, key_range *range_min, } else { MRN_SET_WRAP_SHARE_KEY(share, table->s); MRN_SET_WRAP_TABLE_KEY(this, table); - row_count = wrap_handler->records_in_range(key_nr, range_min, range_max); + row_count = wrap_handler->records_in_range(key_nr, range_min, range_max, + pages); MRN_SET_BASE_SHARE_KEY(share, table->s); MRN_SET_BASE_TABLE_KEY(this, table); } DBUG_RETURN(row_count); } -ha_rows ha_mroonga::storage_records_in_range(uint key_nr, key_range *range_min, - key_range *range_max) +ha_rows ha_mroonga::storage_records_in_range(uint key_nr, + const key_range *range_min, + const key_range *range_max, + page_range *pages) { MRN_DBUG_ENTER_METHOD(); int flags = 0; @@ -7569,8 +7574,8 @@ ha_rows ha_mroonga::storage_records_in_range(uint key_nr, key_range *range_min, } ha_rows ha_mroonga::generic_records_in_range_geo(uint key_nr, - key_range *range_min, - key_range *range_max) + const key_range *range_min, + const key_range *range_max) { MRN_DBUG_ENTER_METHOD(); ha_rows row_count; @@ -7604,15 +7609,17 @@ ha_rows ha_mroonga::generic_records_in_range_geo(uint key_nr, DBUG_RETURN(row_count); } -ha_rows ha_mroonga::records_in_range(uint key_nr, key_range *range_min, key_range *range_max) +ha_rows ha_mroonga::records_in_range(uint key_nr, const key_range *range_min, + const key_range *range_max, + page_range *pages) { MRN_DBUG_ENTER_METHOD(); ha_rows row_count = 0; if (share->wrapper_mode) { - row_count = wrapper_records_in_range(key_nr, range_min, range_max); + row_count = wrapper_records_in_range(key_nr, range_min, range_max, pages); } else { - row_count = storage_records_in_range(key_nr, range_min, range_max); + row_count = storage_records_in_range(key_nr, range_min, range_max, pages); } DBUG_PRINT("info", ("mroonga: row_count=%" MRN_HA_ROWS_FORMAT, row_count)); DBUG_RETURN(row_count); diff --git a/storage/mroonga/ha_mroonga.hpp b/storage/mroonga/ha_mroonga.hpp index fdcb1c4f316..1304cce4504 100644 --- a/storage/mroonga/ha_mroonga.hpp +++ b/storage/mroonga/ha_mroonga.hpp @@ -461,7 +461,8 @@ public: uint max_supported_key_length() const mrn_override; uint max_supported_key_part_length() const mrn_override; - ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key) mrn_override; + ha_rows records_in_range(uint inx, const key_range *min_key, + const key_range *max_key, page_range *pages) mrn_override; int index_init(uint idx, bool sorted) mrn_override; int index_end() mrn_override; #ifndef MRN_HANDLER_HAVE_HA_INDEX_READ_MAP @@ -984,12 +985,14 @@ private: int storage_rnd_pos(uchar *buf, uchar *pos); void wrapper_position(const uchar *record); void storage_position(const uchar *record); - ha_rows wrapper_records_in_range(uint key_nr, key_range *range_min, - key_range *range_max); - ha_rows storage_records_in_range(uint key_nr, key_range *range_min, - key_range *range_max); - ha_rows generic_records_in_range_geo(uint key_nr, key_range *range_min, - key_range *range_max); + ha_rows wrapper_records_in_range(uint key_nr, const key_range *range_min, + const key_range *range_max, + page_range *pages); + ha_rows storage_records_in_range(uint key_nr, const key_range *range_min, + const key_range *range_max, + page_range *pages); + ha_rows generic_records_in_range_geo(uint key_nr, const key_range *range_min, + const key_range *range_max); int wrapper_index_init(uint idx, bool sorted); int storage_index_init(uint idx, bool sorted); int wrapper_index_end(); |