From 8b2f33f87303d86d1d0cd43b1337c60f1f8c63ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 20 Apr 2010 11:29:08 +0300 Subject: [PATCH] Implement UNIV_BTR_AVOID_COPY, an optimization of page splits. --- storage/innodb_plugin/ChangeLog | 6 ++++++ storage/innodb_plugin/btr/btr0btr.c | 20 +++++++++++++++++++- storage/innodb_plugin/include/univ.i | 4 ++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog index 3807c3b6ce4..08962a0c653 100644 --- a/storage/innodb_plugin/ChangeLog +++ b/storage/innodb_plugin/ChangeLog @@ -1,3 +1,9 @@ +2010-04-20 The InnoDB Team + + * btr/btr0btr.c, include/univ.i: + Implement UNIV_BTR_AVOID_COPY, for avoiding writes when a B-tree + node is split at the first or last record. + 2010-04-15 The InnoDB Team * trx/trx0rec.c: diff --git a/storage/innodb_plugin/btr/btr0btr.c b/storage/innodb_plugin/btr/btr0btr.c index fa4fc05d96b..d5018e594a3 100644 --- a/storage/innodb_plugin/btr/btr0btr.c +++ b/storage/innodb_plugin/btr/btr0btr.c @@ -2015,7 +2015,17 @@ insert_right: } /* 5. Move then the records to the new page */ - if (direction == FSP_DOWN) { + if (direction == FSP_DOWN +#ifdef UNIV_BTR_AVOID_COPY + && page_rec_is_supremum(move_limit)) { + /* Instead of moving all records, make the new page + the empty page. */ + + left_block = block; + right_block = new_block; + } else if (direction == FSP_DOWN +#endif /* UNIV_BTR_AVOID_COPY */ + ) { /* fputs("Split left\n", stderr); */ if (0 @@ -2058,6 +2068,14 @@ insert_right: right_block = block; lock_update_split_left(right_block, left_block); +#ifdef UNIV_BTR_AVOID_COPY + } else if (!split_rec) { + /* Instead of moving all records, make the new page + the empty page. */ + + left_block = new_block; + right_block = block; +#endif /* UNIV_BTR_AVOID_COPY */ } else { /* fputs("Split right\n", stderr); */ diff --git a/storage/innodb_plugin/include/univ.i b/storage/innodb_plugin/include/univ.i index dd23cb5ce17..e659ee01cb2 100644 --- a/storage/innodb_plugin/include/univ.i +++ b/storage/innodb_plugin/include/univ.i @@ -205,6 +205,10 @@ operations (very slow); also UNIV_DEBUG must be defined */ adaptive hash index */ #define UNIV_SRV_PRINT_LATCH_WAITS /* enable diagnostic output in sync0sync.c */ +#define UNIV_BTR_AVOID_COPY /* when splitting B-tree nodes, + do not move any records when + all the records would + be moved */ #define UNIV_BTR_PRINT /* enable functions for printing B-trees */ #define UNIV_ZIP_DEBUG /* extensive consistency checks