From 60d31a68a9ccebf80488a1a269fc8da001f1bb9f Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sun, 27 May 2018 21:55:52 +0300 Subject: [PATCH] Bug #81814: InnoDB adaptive hash index uses a bad partitioning algorithm This patch replaces hash-based AHI partitioning with index ID based one. --- storage/innobase/btr/btr0sea.cc | 5 +---- storage/innobase/include/btr0sea.ic | 11 +++-------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc index ee214951c8a..6029687da28 100644 --- a/storage/innobase/btr/btr0sea.cc +++ b/storage/innobase/btr/btr0sea.cc @@ -1092,10 +1092,7 @@ void btr_search_drop_page_hash_index(buf_block_t *block) { Determine the ahi_slot based on the block contents. */ const space_index_t index_id = btr_page_get_index_id(block->frame); - const ulint ahi_slot = - ut_fold_ulint_pair(static_cast(index_id), - static_cast(block->page.id.space())) % - btr_ahi_parts; + const ulint ahi_slot = static_cast(index_id) % btr_ahi_parts; latch = btr_search_latches[ahi_slot]; ut_ad(!btr_search_own_any(RW_LOCK_S)); diff --git a/storage/innobase/include/btr0sea.ic b/storage/innobase/include/btr0sea.ic index 4fafa743f9e..cfe3eb8899f 100644 --- a/storage/innobase/include/btr0sea.ic +++ b/storage/innobase/include/btr0sea.ic @@ -182,10 +182,7 @@ UNIV_INLINE rw_lock_t *btr_get_search_latch(const dict_index_t *index) { ut_ad(index != NULL); - ulint ifold = ut_fold_ulint_pair(static_cast(index->id), - static_cast(index->space)); - - return (btr_search_latches[ifold % btr_ahi_parts]); + return (btr_search_latches[static_cast(index->id) % btr_ahi_parts]); } /** Get the hash-table based on index attributes. @@ -196,8 +193,6 @@ UNIV_INLINE hash_table_t *btr_get_search_table(const dict_index_t *index) { ut_ad(index != NULL); - ulint ifold = ut_fold_ulint_pair(static_cast(index->id), - static_cast(index->space)); - - return (btr_search_sys->hash_tables[ifold % btr_ahi_parts]); + return (btr_search_sys->hash_tables[static_cast(index->id) % + btr_ahi_parts]); }