Commit 4106db3e authored by Sergei Golubchik's avatar Sergei Golubchik

Optimize use of SEARCH_SAVE_BUFF in Aria

(less not-needed copies of key pages)

storage/maria/ma_rkey.c:
  Fixed wrong test if SEARCH_SAVE_BUFF should be set.
  Now we assume that if we are doing HA_READ_KEY_EXACT,
  we don't have to copy the last key buffer
  (in other words, it's not likely this will be followed
  by a read-next call)
parent 53ef653f
......@@ -83,10 +83,11 @@ int maria_rkey(MARIA_HA *info, uchar *buf, int inx, const uchar *key_data,
rw_rdlock(&keyinfo->root_lock);
nextflag= maria_read_vec[search_flag] | key.flag;
if (search_flag != HA_READ_KEY_EXACT ||
((keyinfo->flag & (HA_NOSAME | HA_NULL_PART)) != HA_NOSAME))
if (search_flag != HA_READ_KEY_EXACT)
{
/* Assume we will get a read next/previous call after this one */
nextflag|= SEARCH_SAVE_BUFF;
}
switch (keyinfo->key_alg) {
#ifdef HAVE_RTREE_KEYS
case HA_KEY_ALG_RTREE:
......@@ -103,8 +104,6 @@ int maria_rkey(MARIA_HA *info, uchar *buf, int inx, const uchar *key_data,
if (!_ma_search(info, &key, nextflag, info->s->state.key_root[inx]))
{
MARIA_KEY lastkey;
lastkey.keyinfo= keyinfo;
lastkey.data= info->lastkey_buff;
/*
Found a key, but it might not be usable. We cannot use rows that
are inserted by other threads after we got our table lock
......@@ -129,6 +128,8 @@ int maria_rkey(MARIA_HA *info, uchar *buf, int inx, const uchar *key_data,
break;
}
lastkey.keyinfo= keyinfo;
lastkey.data= info->lastkey_buff;
do
{
uint not_used[2];
......
......@@ -45,7 +45,8 @@ my_bool _ma_check_unique(MARIA_HA *info, MARIA_UNIQUEDEF *def, uchar *record,
info->update&= ~HA_STATE_RNEXT_SAME;
DBUG_ASSERT(key.data_length == MARIA_UNIQUE_HASH_LENGTH);
if (_ma_search(info, &key, SEARCH_FIND, info->s->state.key_root[def->key]))
if (_ma_search(info, &key, SEARCH_FIND | SEARCH_SAVE_BUFF,
info->s->state.key_root[def->key]))
{
info->page_changed=1; /* Can't optimize read next */
info->cur_row.lastpos= lastpos;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment