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 /include | |
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 'include')
-rw-r--r-- | include/heap.h | 5 | ||||
-rw-r--r-- | include/maria.h | 4 | ||||
-rw-r--r-- | include/my_base.h | 11 | ||||
-rw-r--r-- | include/myisam.h | 4 | ||||
-rw-r--r-- | include/myisammrg.h | 4 |
5 files changed, 23 insertions, 5 deletions
diff --git a/include/heap.h b/include/heap.h index b734f8ae88d..f0ac527976c 100644 --- a/include/heap.h +++ b/include/heap.h @@ -239,8 +239,9 @@ extern int heap_disable_indexes(HP_INFO *info); extern int heap_enable_indexes(HP_INFO *info); extern int heap_indexes_are_disabled(HP_INFO *info); extern void heap_update_auto_increment(HP_INFO *info, const uchar *record); -ha_rows hp_rb_records_in_range(HP_INFO *info, int inx, key_range *min_key, - key_range *max_key); +ha_rows hp_rb_records_in_range(HP_INFO *info, int inx, + const key_range *min_key, + const key_range *max_key); int hp_panic(enum ha_panic_function flag); int heap_rkey(HP_INFO *info, uchar *record, int inx, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag); diff --git a/include/maria.h b/include/maria.h index 2c711b0d31d..a4c425ced47 100644 --- a/include/maria.h +++ b/include/maria.h @@ -324,7 +324,9 @@ extern int maria_extra(MARIA_HA *file, enum ha_extra_function function, void *extra_arg); extern int maria_reset(MARIA_HA *file); extern ha_rows maria_records_in_range(MARIA_HA *info, int inx, - key_range *min_key, key_range *max_key); + const key_range *min_key, + const key_range *max_key, + page_range *page); extern int maria_is_changed(MARIA_HA *info); extern int maria_delete_all_rows(MARIA_HA *info); extern uint maria_get_pointer_length(ulonglong file_length, uint def); diff --git a/include/my_base.h b/include/my_base.h index e73844d0937..5bc778655dc 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -636,6 +636,17 @@ typedef struct st_key_multi_range } KEY_MULTI_RANGE; +/* Store first and last leaf page accessed by records_in_range */ + +typedef struct st_page_range +{ + ulonglong first_page; + ulonglong last_page; +} page_range; + +#define UNUSED_PAGE_NO ULONGLONG_MAX +#define unused_page_range { UNUSED_PAGE_NO, UNUSED_PAGE_NO } + /* For number of records */ #ifdef BIG_TABLES #define rows2double(A) ulonglong2double(A) diff --git a/include/myisam.h b/include/myisam.h index dfd5676a4d8..0942584e874 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -291,7 +291,9 @@ extern int mi_extra(struct st_myisam_info *file, void *extra_arg); extern int mi_reset(struct st_myisam_info *file); extern ha_rows mi_records_in_range(MI_INFO *info,int inx, - key_range *min_key, key_range *max_key); + const key_range *min_key, + const key_range *max_key, + page_range *pages); extern int mi_log(int activate_log); extern int mi_is_changed(struct st_myisam_info *info); extern int mi_delete_all_rows(struct st_myisam_info *info); diff --git a/include/myisammrg.h b/include/myisammrg.h index 76286000ff5..78e7ac00e8f 100644 --- a/include/myisammrg.h +++ b/include/myisammrg.h @@ -116,7 +116,9 @@ extern int myrg_extra(MYRG_INFO *file,enum ha_extra_function function, extern int myrg_reset(MYRG_INFO *info); extern void myrg_extrafunc(MYRG_INFO *info,invalidator_by_filename inv); extern ha_rows myrg_records_in_range(MYRG_INFO *info, int inx, - key_range *min_key, key_range *max_key); + const key_range *min_key, + const key_range *max_key, + page_range *pages); extern ha_rows myrg_records(MYRG_INFO *info); extern ulonglong myrg_position(MYRG_INFO *info); |