diff options
author | unknown <heikki@hundin.mysql.fi> | 2004-03-19 22:51:25 +0200 |
---|---|---|
committer | unknown <heikki@hundin.mysql.fi> | 2004-03-19 22:51:25 +0200 |
commit | 72d15bccaae54d985dcccb796ecd90d29c65ce5c (patch) | |
tree | 0379efa1911b44cc61a175166283223328c24f98 /innobase/btr/btr0btr.c | |
parent | eb72cf66499a32f4f4369ffd84fa0e89c89a58ab (diff) | |
download | mariadb-git-72d15bccaae54d985dcccb796ecd90d29c65ce5c.tar.gz |
btr0btr.c:
Improve space utilization if we have 3 kB - 8 kB rows to insert in the order of the primary key
btr0cur.c:
Fix bug: The row count and key cardinality estimate was grossly too small if each clustered index page only contained one record
innobase/btr/btr0cur.c:
Fix bug: The row count and key cardinality estimate was grossly too small if each clustered index page only contained one record
innobase/btr/btr0btr.c:
Improve space utilization if we have 3 kB - 8 kB rows to insert in the order of the primary key
Diffstat (limited to 'innobase/btr/btr0btr.c')
-rw-r--r-- | innobase/btr/btr0btr.c | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/innobase/btr/btr0btr.c b/innobase/btr/btr0btr.c index 71be6d81d7c..1c3e033a8d7 100644 --- a/innobase/btr/btr0btr.c +++ b/innobase/btr/btr0btr.c @@ -76,9 +76,6 @@ make them consecutive on disk if possible. From the other file segment we allocate pages for the non-leaf levels of the tree. */ -/* If this many inserts occur sequentially, it affects page split */ -#define BTR_PAGE_SEQ_INSERT_LIMIT 5 - /****************************************************************** Creates a new index page to the tree (not the root, and also not used in page reorganization). */ @@ -1086,18 +1083,18 @@ btr_page_get_split_rec_to_left( page = btr_cur_get_page(cursor); insert_point = btr_cur_get_rec(cursor); - if ((page_header_get_ptr(page, PAGE_LAST_INSERT) - == page_rec_get_next(insert_point)) - && (page_header_get_field(page, PAGE_DIRECTION) == PAGE_LEFT) - && ((page_header_get_field(page, PAGE_N_DIRECTION) - >= BTR_PAGE_SEQ_INSERT_LIMIT) - || (page_header_get_field(page, PAGE_N_DIRECTION) + 1 - >= page_get_n_recs(page)))) { + if (page_header_get_ptr(page, PAGE_LAST_INSERT) + == page_rec_get_next(insert_point)) { infimum = page_get_infimum_rec(page); - - if ((infimum != insert_point) - && (page_rec_get_next(infimum) != insert_point)) { + + /* If the convergence is in the middle of a page, include also + the record immediately before the new insert to the upper + page. Otherwise, we could repeatedly move from page to page + lots of records smaller than the convergence point. */ + + if (infimum != insert_point + && page_rec_get_next(infimum) != insert_point) { *split_rec = insert_point; } else { @@ -1131,29 +1128,29 @@ btr_page_get_split_rec_to_right( page = btr_cur_get_page(cursor); insert_point = btr_cur_get_rec(cursor); - if ((page_header_get_ptr(page, PAGE_LAST_INSERT) == insert_point) - && (page_header_get_field(page, PAGE_DIRECTION) == PAGE_RIGHT) - && ((page_header_get_field(page, PAGE_N_DIRECTION) - >= BTR_PAGE_SEQ_INSERT_LIMIT) - || (page_header_get_field(page, PAGE_N_DIRECTION) + 1 - >= page_get_n_recs(page)))) { + /* We use eager heuristics: if the new insert would be right after + the previous insert on the same page, we assume that there is a + pattern of sequential inserts here. */ + + if (page_header_get_ptr(page, PAGE_LAST_INSERT) == insert_point) { supremum = page_get_supremum_rec(page); - if ((page_rec_get_next(insert_point) != supremum) - && (page_rec_get_next(page_rec_get_next(insert_point)) - != supremum) - && (page_rec_get_next(page_rec_get_next( - page_rec_get_next(insert_point))) - != supremum)) { - - /* If there are >= 3 user records up from the insert - point, split all but 2 off */ - - *split_rec = page_rec_get_next(page_rec_get_next( - page_rec_get_next(insert_point))); + if (page_rec_get_next(insert_point) != supremum + && page_rec_get_next(page_rec_get_next(insert_point)) + != supremum) { + + /* If there are >= 2 user records up from the insert + point, split all but 1 off. We want to keep one because + then sequential inserts can use the adaptive hash + index, as they can do the necessary checks of the right + search position just by looking at the records on this + page. */ + + *split_rec = page_rec_get_next( + page_rec_get_next(insert_point)); } else { - /* Else split at inserted record */ + /* Else split at the new record to insert */ *split_rec = NULL; } |