summaryrefslogtreecommitdiff
path: root/storage/myisammrg
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2020-02-27 19:12:27 +0200
committerMonty <monty@mariadb.org>2020-03-27 03:54:45 +0200
commitf36ca142f7fa59598e34e842b60372b963067766 (patch)
tree4b797dcf88e98fd9fe83e3a29bfaabc10b7219c2 /storage/myisammrg
parent9b061990801b5c8309149794145f9c361bb8cfc6 (diff)
downloadmariadb-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/myisammrg')
-rw-r--r--storage/myisammrg/ha_myisammrg.cc9
-rw-r--r--storage/myisammrg/ha_myisammrg.h3
-rw-r--r--storage/myisammrg/myrg_range.c11
3 files changed, 17 insertions, 6 deletions
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
index 4fd63020c6a..2a7ca8d51f8 100644
--- a/storage/myisammrg/ha_myisammrg.cc
+++ b/storage/myisammrg/ha_myisammrg.cc
@@ -1216,11 +1216,14 @@ void ha_myisammrg::position(const uchar *record)
}
-ha_rows ha_myisammrg::records_in_range(uint inx, key_range *min_key,
- key_range *max_key)
+ha_rows ha_myisammrg::records_in_range(uint inx,
+ const key_range *min_key,
+ const key_range *max_key,
+ page_range *pages)
{
DBUG_ASSERT(this->file->children_attached);
- return (ha_rows) myrg_records_in_range(file, (int) inx, min_key, max_key);
+ return (ha_rows) myrg_records_in_range(file, (int) inx, min_key, max_key,
+ pages);
}
diff --git a/storage/myisammrg/ha_myisammrg.h b/storage/myisammrg/ha_myisammrg.h
index b7cbd6c7d12..d5d62a002aa 100644
--- a/storage/myisammrg/ha_myisammrg.h
+++ b/storage/myisammrg/ha_myisammrg.h
@@ -129,7 +129,8 @@ public:
int rnd_next(uchar *buf);
int rnd_pos(uchar * buf, uchar *pos);
void position(const uchar *record);
- 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);
int delete_all_rows();
int info(uint);
int reset(void);
diff --git a/storage/myisammrg/myrg_range.c b/storage/myisammrg/myrg_range.c
index 893bda20833..da5e2c38d68 100644
--- a/storage/myisammrg/myrg_range.c
+++ b/storage/myisammrg/myrg_range.c
@@ -17,14 +17,21 @@
#include "myrg_def.h"
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)
{
ha_rows records=0, res;
MYRG_TABLE *table;
+ page_range ignore_pages;
+
+ /* Don't calculate pages of more than one active partition */
+ if (info->open_tables +1 != info->end_table)
+ pages= &ignore_pages;
for (table=info->open_tables ; table != info->end_table ; table++)
{
- res= mi_records_in_range(table->table, inx, min_key, max_key);
+ res= mi_records_in_range(table->table, inx, min_key, max_key, pages);
if (res == HA_POS_ERROR)
return HA_POS_ERROR;
if (records > HA_POS_ERROR - res)