Commit 569675f7 authored by ram@mysql.r18.ru's avatar ram@mysql.r18.ru

rtree_find_X functions speed-up: we don't need to store whole key buffer for next search.

Code clean-up.
parent f4e1a2f2
...@@ -69,12 +69,6 @@ static int rtree_find_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint search_flag, u ...@@ -69,12 +69,6 @@ static int rtree_find_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint search_flag, u
if(info->rtree_recursion_depth >= level) if(info->rtree_recursion_depth >= level)
{ {
k = page_buf + *saved_key; k = page_buf + *saved_key;
if (!nod_flag)
{
/* Only leaf pages contain data references. */
/* Need to check next key with data reference. */
k = rt_PAGE_NEXT_KEY(k, k_len, nod_flag);
}
} }
else else
{ {
...@@ -116,13 +110,13 @@ static int rtree_find_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint search_flag, u ...@@ -116,13 +110,13 @@ static int rtree_find_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint search_flag, u
info->lastkey_length = k_len + info->s->base.rec_reflength; info->lastkey_length = k_len + info->s->base.rec_reflength;
memcpy(info->lastkey, k, info->lastkey_length); memcpy(info->lastkey, k, info->lastkey_length);
info->rtree_recursion_depth = level; info->rtree_recursion_depth = level;
*saved_key = k - page_buf; *saved_key = last - page_buf;
if (after_key < last) if (after_key < last)
{ {
info->int_keypos = (uchar*)saved_key; info->int_keypos = info->buff;
memcpy(info->buff, page_buf, keyinfo->block_length); info->int_maxpos = info->buff + (last - after_key);
info->int_maxpos = rt_PAGE_END(info->buff); memcpy(info->buff, after_key, last - after_key);
info->buff_used = 0; info->buff_used = 0;
} }
else else
...@@ -193,34 +187,32 @@ int rtree_find_next(MI_INFO *info, uint keynr, uint search_flag) ...@@ -193,34 +187,32 @@ int rtree_find_next(MI_INFO *info, uint keynr, uint search_flag)
if (!info->buff_used) if (!info->buff_used)
{ {
uint k_len = keyinfo->keylength - info->s->base.rec_reflength; uchar *key = info->int_keypos;
/* rt_PAGE_NEXT_KEY(info->int_keypos) */
uchar *key = info->buff + *(int*)info->int_keypos + k_len +
info->s->base.rec_reflength;
while (key < info->int_maxpos) while (key < info->int_maxpos)
{ {
if (!rtree_key_cmp(keyinfo->seg, info->lastkey2, key, if (!rtree_key_cmp(keyinfo->seg, info->lastkey2, key,
info->last_rkey_length, search_flag)) info->last_rkey_length, search_flag))
{ {
/* rt_PAGE_NEXT_KEY(key) */ uchar *after_key = key + keyinfo->keylength;
uchar *after_key = key + k_len + info->s->base.rec_reflength;
info->lastpos = _mi_dpos(info, 0, after_key); info->lastpos = _mi_dpos(info, 0, after_key);
info->lastkey_length = k_len + info->s->base.rec_reflength;
memcpy(info->lastkey, key, info->lastkey_length); memcpy(info->lastkey, key, info->lastkey_length);
*(int*)info->int_keypos = key - info->buff; if (after_key < info->int_maxpos)
if (after_key >= info->int_maxpos)
{ {
info->buff_used = 1; info->int_keypos = after_key;
}
else
{
info->buff_used = 1;
} }
return 0; return 0;
} }
else else
{ {
key += k_len + info->s->base.rec_reflength; key += keyinfo->keylength;
} }
} }
} }
......
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