[RFC PATCH 01/23] vinyl: do not turn REPLACE into INSERT when processing DML request
Vladimir Davydov
vdavydov.dev at gmail.com
Sun Jul 8 19:48:32 MSK 2018
Since in presence of secondary indexes we read the primary index when
processing a REPLACE request anyway, we turn it into INSERT if no tuple
matching the new tuple is found so that INSERT+DELETE gets annihilated
on compaction.
However, in the scope of #2129 we are planning to optimize the read out
so that this transformation won't be possible anymore. So let's remove
it now.
Needed for #2129
---
src/box/vinyl.c | 8 --------
test/vinyl/layout.result | 20 ++++++++++----------
test/vinyl/write_iterator.result | 6 ------
test/vinyl/write_iterator.test.lua | 2 --
4 files changed, 10 insertions(+), 26 deletions(-)
diff --git a/src/box/vinyl.c b/src/box/vinyl.c
index 6dd22884..f9c2843e 100644
--- a/src/box/vinyl.c
+++ b/src/box/vinyl.c
@@ -1540,14 +1540,6 @@ vy_replace_impl(struct vy_env *env, struct vy_tx *tx, struct space *space,
new_stmt, &old_stmt) != 0)
goto error;
- if (old_stmt == NULL) {
- /*
- * We can turn REPLACE into INSERT if the new key
- * does not have history.
- */
- vy_stmt_set_type(new_stmt, IPROTO_INSERT);
- }
-
/*
* Replace in the primary index without explicit deletion
* of the old tuple.
diff --git a/test/vinyl/layout.result b/test/vinyl/layout.result
index 49826302..1f928a8f 100644
--- a/test/vinyl/layout.result
+++ b/test/vinyl/layout.result
@@ -253,17 +253,17 @@ result
- - 00000000000000000008.run
- - HEADER:
lsn: 10
- type: INSERT
+ type: REPLACE
BODY:
tuple: ['ёёё', null]
- HEADER:
lsn: 9
- type: INSERT
+ type: REPLACE
BODY:
tuple: ['эээ', null]
- HEADER:
lsn: 8
- type: INSERT
+ type: REPLACE
BODY:
tuple: ['ЭЭЭ', null]
- HEADER:
@@ -297,12 +297,12 @@ result
tuple: ['ёёё', 123]
- HEADER:
lsn: 13
- type: INSERT
+ type: REPLACE
BODY:
tuple: ['ююю', 789]
- HEADER:
lsn: 12
- type: INSERT
+ type: REPLACE
BODY:
tuple: ['ЮЮЮ', 456]
- HEADER:
@@ -331,17 +331,17 @@ result
- - 00000000000000000006.run
- - HEADER:
lsn: 10
- type: INSERT
+ type: REPLACE
BODY:
tuple: [null, 'ёёё']
- HEADER:
lsn: 9
- type: INSERT
+ type: REPLACE
BODY:
tuple: [null, 'эээ']
- HEADER:
lsn: 8
- type: INSERT
+ type: REPLACE
BODY:
tuple: [null, 'ЭЭЭ']
- HEADER:
@@ -380,12 +380,12 @@ result
tuple: [123, 'ёёё']
- HEADER:
lsn: 12
- type: INSERT
+ type: REPLACE
BODY:
tuple: [456, 'ЮЮЮ']
- HEADER:
lsn: 13
- type: INSERT
+ type: REPLACE
BODY:
tuple: [789, 'ююю']
- HEADER:
diff --git a/test/vinyl/write_iterator.result b/test/vinyl/write_iterator.result
index c38de5d3..162d8463 100644
--- a/test/vinyl/write_iterator.result
+++ b/test/vinyl/write_iterator.result
@@ -765,9 +765,6 @@ box.snapshot()
_ = s:insert{1, 1} -- insert
---
...
-_ = s:replace{2, 2} -- replace, no old tuple
----
-...
_ = s:upsert({3, 3}, {{'!', 1, 1}}) -- upsert, no old tuple
---
...
@@ -794,9 +791,6 @@ box.snapshot()
s:delete{1}
---
...
-s:delete{2}
----
-...
s:delete{3}
---
...
diff --git a/test/vinyl/write_iterator.test.lua b/test/vinyl/write_iterator.test.lua
index 73c90c42..9a6cc480 100644
--- a/test/vinyl/write_iterator.test.lua
+++ b/test/vinyl/write_iterator.test.lua
@@ -326,7 +326,6 @@ for i = 1001, 1000 + PAD1 do s:replace{i, i} end
box.snapshot()
-- Generate some INSERT statements and dump them to disk.
_ = s:insert{1, 1} -- insert
-_ = s:replace{2, 2} -- replace, no old tuple
_ = s:upsert({3, 3}, {{'!', 1, 1}}) -- upsert, no old tuple
box.begin() s:insert{4, 4} s:delete(4) box.commit()
box.begin() s:insert{5, 5} s:replace{5, 5, 5} box.commit()
@@ -336,7 +335,6 @@ _ = s:insert{8, 8}
box.snapshot()
-- Delete the inserted tuples and trigger compaction.
s:delete{1}
-s:delete{2}
s:delete{3}
s:delete{4}
s:delete{5}
--
2.11.0
More information about the Tarantool-patches
mailing list