From d73241c0a93a4d1ae198b3c59a0f8da84adb295f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 30 Apr 2018 10:28:50 +0300 Subject: [PATCH] Simplify dict_stats_analyze_index_level() Only allocate n_uniq elements for offsets, instead of index->n_fields. (Statistics are never computed on spatial indexes, so we never need to access more fields even in rec_copy_prefix_to_buf().) --- storage/innobase/dict/dict0stats.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc index 06b8c81ad57..4a2fbe32243 100644 --- a/storage/innobase/dict/dict0stats.cc +++ b/storage/innobase/dict/dict0stats.cc @@ -1039,10 +1039,10 @@ dict_stats_analyze_index_level( memset(n_diff, 0x0, n_uniq * sizeof(n_diff[0])); /* Allocate space for the offsets header (the allocation size at - offsets[0] and the REC_OFFS_HEADER_SIZE bytes), and n_fields + 1, + offsets[0] and the REC_OFFS_HEADER_SIZE bytes), and n_uniq + 1, so that this will never be less than the size calculated in rec_get_offsets_func(). */ - i = (REC_OFFS_HEADER_SIZE + 1 + 1) + unsigned(index->n_fields); + i = (REC_OFFS_HEADER_SIZE + 1 + 1) + n_uniq; heap = mem_heap_create((2 * sizeof *rec_offsets) * i); rec_offsets = static_cast( @@ -1158,8 +1158,7 @@ dict_stats_analyze_index_level( n_uniq, &heap); prev_rec = rec_copy_prefix_to_buf( - prev_rec, index, - rec_offs_n_fields(prev_rec_offsets), + prev_rec, index, n_uniq, &prev_rec_buf, &prev_rec_buf_size); prev_rec_is_copied = true; @@ -1232,7 +1231,7 @@ dict_stats_analyze_index_level( btr_pcur_move_to_next_user_rec() will release the latch on the page that prev_rec is on */ prev_rec = rec_copy_prefix_to_buf( - rec, index, rec_offs_n_fields(rec_offsets), + rec, index, n_uniq, &prev_rec_buf, &prev_rec_buf_size); prev_rec_is_copied = true;