Skip to content
Permalink
Browse files

Bug#21198396 REINTRODUCE ADAPTIVE HASH INDEX FIELD PREFIXES

TO SPEED UP SEQUENTIAL INSERTS

This is a regression from the fix of
Bug#16852278 SIMPLIFY RECORD COMPARISONS
which removed the n_bytes fields from the adaptive hash index.

For certain workloads, such as LOAD DATA INFILE of sorted data,
the ability of the adaptive hash index to build indexes on
byte prefixes of arbitrary binary fields is essential.
In the reported test case, there is an integer primary key,
and we end up building adaptive hash indexes on the
most significant bytes of this key.

This patch will bring back the n_bytes fields by introducing
variants of the low-level functions.
The whole-field comparison functions will be left unchanged.

btr_cur_t: Bring back up_bytes, low_bytes.
btr_search_t: Bring back n_bytes.
buf_block_t: Bring back n_bytes, curr_n_bytes.

dtuple_fold(), rec_fold(), btr_search_build_page_hash_index():
Bring back n_bytes.

page_cur_search_with_match_bytes():
A variant of page_cur_search_with_match().

cmp_dtuple_rec_with_match_bytes():
A variant of cmp_dtuple_rec_with_match().

page_cur_try_search_shortcut_bytes():
A variant of page_cur_try_search_shortcut().

ut_pair_min(), ut_pair_cmp(): Bring back these.

cmp_get_pad_char(): Bring back this.
It was previously called dtype_get_pad_char().

RB: 8961
Reviewed-by: Jimmy Yang <jimmy.yang@oracle.com>
Reviewed-by: Krunal Bauskar <krunal.bauskar@oracle.com>
  • Loading branch information...
Marko Mäkelä
Marko Mäkelä committed Jun 11, 2015
1 parent 24d67f9 commit 00ec81a9efc1108376813f15935b52c451a268cf
@@ -758,7 +758,9 @@ btr_cur_search_to_nth_level(
buf_block_t* guess;
ulint height;
ulint up_match;
ulint up_bytes;
ulint low_match;
ulint low_bytes;
ulint savepoint;
ulint rw_latch;
page_cur_mode_t page_mode;
@@ -814,7 +816,9 @@ btr_cur_search_to_nth_level(
ut_ad(index->page != FIL_NULL);

UNIV_MEM_INVALID(&cursor->up_match, sizeof cursor->up_match);
UNIV_MEM_INVALID(&cursor->up_bytes, sizeof cursor->up_bytes);
UNIV_MEM_INVALID(&cursor->low_match, sizeof cursor->low_match);
UNIV_MEM_INVALID(&cursor->low_bytes, sizeof cursor->low_bytes);
#ifdef UNIV_DEBUG
cursor->up_match = ULINT_UNDEFINED;
cursor->low_match = ULINT_UNDEFINED;
@@ -1026,7 +1030,9 @@ btr_cur_search_to_nth_level(
}

up_match = 0;
up_bytes = 0;
low_match = 0;
low_bytes = 0;

height = ULINT_UNDEFINED;

@@ -1391,9 +1397,10 @@ btr_cur_search_to_nth_level(
}

if (dict_index_is_spatial(index) && page_mode >= PAGE_CUR_CONTAIN) {
ut_ad(need_path);
found = rtr_cur_search_with_match(
block, index, tuple, page_mode, page_cursor,
need_path ? cursor->rtr_info : NULL);
cursor->rtr_info);

/* Need to use BTR_MODIFY_TREE to do the MBR adjustment */
if (search_mode == PAGE_CUR_RTREE_INSERT
@@ -1410,7 +1417,18 @@ btr_cur_search_to_nth_level(
ut_ad(0);
}
}
} else if (height == 0 && btr_search_enabled
&& !dict_index_is_spatial(index)) {
/* The adaptive hash index is only used when searching
for leaf pages (height==0), but not in r-trees.
We only need the byte prefix comparison for the purpose
of updating the adaptive hash index. */
page_cur_search_with_match_bytes(
block, index, tuple, page_mode, &up_match, &up_bytes,
&low_match, &low_bytes, page_cursor);
} else {
/* Search for complete index fields. */
up_bytes = low_bytes = 0;
page_cur_search_with_match(
block, index, tuple, page_mode, &up_match,
&low_match, page_cursor,
@@ -1732,13 +1750,15 @@ btr_cur_search_to_nth_level(
/* replay up_match, low_match */
up_match = 0;
low_match = 0;
rtr_info_t* rtr_info = need_path
? cursor->rtr_info : NULL;

for (ulint i = 0; i < n_blocks; i++) {
page_cur_search_with_match(
tree_blocks[i], index, tuple,
page_mode, &up_match,
&low_match, page_cursor,
need_path ? cursor->rtr_info
: NULL);
rtr_info);
}

goto search_loop;
@@ -1763,8 +1783,10 @@ btr_cur_search_to_nth_level(
goto retry_page_get;
}

if (dict_index_is_spatial(index) && need_path
if (dict_index_is_spatial(index)
&& page_mode >= PAGE_CUR_CONTAIN
&& page_mode != PAGE_CUR_RTREE_INSERT) {
ut_ad(need_path);
rtr_node_path_t* path =
cursor->rtr_info->path;

@@ -1873,7 +1895,9 @@ btr_cur_search_to_nth_level(
}
} else {
cursor->low_match = low_match;
cursor->low_bytes = low_bytes;
cursor->up_match = up_match;
cursor->up_bytes = up_bytes;

#ifdef BTR_CUR_ADAPT
/* We do a dirty read of btr_search_enabled here. We

0 comments on commit 00ec81a

Please sign in to comment.
You can’t perform that action at this time.