Commit efc82fb8 authored by mmakela's avatar mmakela

branches/innodb+: Buffer DELETE and purge on UNIQUE indexes. Sunny

noted that the check for ignore_secondary_unique might not be disabled
for deletes.  Indeed, I see no reason for the check to exist for deletes.

btr_op_enum: Document the constants. Add BTR_INSERT_IGNORE_UNIQUE_OP.

btr_cur_search_to_nth_level(): Remove the variable
ignore_sec_unique. Use btr_op instead. Invoke ibuf_should_try() with
ignore_sec_unique = (btr_op != BTR_INSERT_OP), that is, always ignore
the UNIQUE constraint when buffering delete-mark and purge.

BTR_IGNORE_SEC_UNIQUE: Note that the flag only makes sense in
conjunction with BTR_INSERT.

rb://274 approved by Sunny Bains.  This addresses Issue #471.
parent 66ed2719
...@@ -68,12 +68,13 @@ Created 10/16/1994 Heikki Tuuri ...@@ -68,12 +68,13 @@ Created 10/16/1994 Heikki Tuuri
#include "lock0lock.h" #include "lock0lock.h"
#include "zlib.h" #include "zlib.h"
/* Btree operation types, introduced as part of delete buffering. */ /** Buffered B-tree operation types, introduced as part of delete buffering. */
typedef enum btr_op_enum { typedef enum btr_op_enum {
BTR_NO_OP = 0, BTR_NO_OP = 0, /*!< Not buffered */
BTR_INSERT_OP, BTR_INSERT_OP, /*!< Insert, do not ignore UNIQUE */
BTR_DELETE_OP, BTR_INSERT_IGNORE_UNIQUE_OP, /*!< Insert, ignoring UNIQUE */
BTR_DELMARK_OP BTR_DELETE_OP, /*!< Purge a delete-marked record */
BTR_DELMARK_OP /*!< Mark a record for deletion */
} btr_op_t; } btr_op_t;
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
...@@ -375,8 +376,7 @@ btr_cur_search_to_nth_level( ...@@ -375,8 +376,7 @@ btr_cur_search_to_nth_level(
ulint estimate; ulint estimate;
ulint zip_size; ulint zip_size;
page_cur_t* page_cursor; page_cur_t* page_cursor;
ulint ignore_sec_unique; btr_op_t btr_op;
btr_op_t btr_op = BTR_NO_OP;
ulint root_height = 0; /* remove warning */ ulint root_height = 0; /* remove warning */
#ifdef BTR_CUR_ADAPT #ifdef BTR_CUR_ADAPT
...@@ -406,9 +406,12 @@ btr_cur_search_to_nth_level( ...@@ -406,9 +406,12 @@ btr_cur_search_to_nth_level(
& (BTR_INSERT | BTR_DELETE | BTR_DELETE_MARK), & (BTR_INSERT | BTR_DELETE | BTR_DELETE_MARK),
0)) { 0)) {
case 0: case 0:
btr_op = BTR_NO_OP;
break; break;
case BTR_INSERT: case BTR_INSERT:
btr_op = BTR_INSERT_OP; btr_op = (latch_mode & BTR_IGNORE_SEC_UNIQUE)
? BTR_INSERT_IGNORE_UNIQUE_OP
: BTR_INSERT_OP;
break; break;
case BTR_DELETE: case BTR_DELETE:
btr_op = BTR_DELETE_OP; btr_op = BTR_DELETE_OP;
...@@ -429,7 +432,6 @@ btr_cur_search_to_nth_level( ...@@ -429,7 +432,6 @@ btr_cur_search_to_nth_level(
ut_ad(btr_op == BTR_NO_OP || !dict_index_is_clust(index)); ut_ad(btr_op == BTR_NO_OP || !dict_index_is_clust(index));
estimate = latch_mode & BTR_ESTIMATE; estimate = latch_mode & BTR_ESTIMATE;
ignore_sec_unique = latch_mode & BTR_IGNORE_SEC_UNIQUE;
/* Turn the flags unrelated to the latch mode off. */ /* Turn the flags unrelated to the latch mode off. */
latch_mode &= ~(BTR_INSERT latch_mode &= ~(BTR_INSERT
...@@ -573,7 +575,7 @@ search_loop: ...@@ -573,7 +575,7 @@ search_loop:
rw_latch = latch_mode; rw_latch = latch_mode;
if (btr_op != BTR_NO_OP if (btr_op != BTR_NO_OP
&& ibuf_should_try(index, ignore_sec_unique)) { && ibuf_should_try(index, btr_op != BTR_INSERT_OP)) {
/* Try to buffer the operation if the leaf /* Try to buffer the operation if the leaf
page is not in the buffer pool. */ page is not in the buffer pool. */
...@@ -600,6 +602,7 @@ retry_page_get: ...@@ -600,6 +602,7 @@ retry_page_get:
switch (btr_op) { switch (btr_op) {
case BTR_INSERT_OP: case BTR_INSERT_OP:
case BTR_INSERT_IGNORE_UNIQUE_OP:
ut_ad(buf_mode == BUF_GET_IF_IN_POOL); ut_ad(buf_mode == BUF_GET_IF_IN_POOL);
if (ibuf_insert(IBUF_OP_INSERT, tuple, index, if (ibuf_insert(IBUF_OP_INSERT, tuple, index,
......
...@@ -79,7 +79,7 @@ When the record is not in the buffer pool, try to use the insert buffer. */ ...@@ -79,7 +79,7 @@ When the record is not in the buffer pool, try to use the insert buffer. */
optimization */ optimization */
#define BTR_ESTIMATE 1024 #define BTR_ESTIMATE 1024
/** This flag ORed to btr_latch_mode says that we can ignore possible /** This flag ORed to BTR_INSERT says that we can ignore possible
UNIQUE definition on secondary indexes when we decide if we can use UNIQUE definition on secondary indexes when we decide if we can use
the insert buffer to speed up inserts */ the insert buffer to speed up inserts */
#define BTR_IGNORE_SEC_UNIQUE 2048 #define BTR_IGNORE_SEC_UNIQUE 2048
......
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