From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Tue, 30 Oct 2018 11:45:12 +0300 From: Vladimir Davydov Subject: Re: [tarantool-patches] [PATCH 1/2] space: add method to fetch next rowid Message-ID: <20181030084512.li7q5llgflczchf7@esperanza> References: <11f65a415a9b1101fa4ba816be237df524de9b47.1540838910.git.korablev@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <11f65a415a9b1101fa4ba816be237df524de9b47.1540838910.git.korablev@tarantool.org> To: Nikita Pettik Cc: tarantool-patches@freelists.org, v.shpilevoy@tarantool.org List-ID: On Mon, Oct 29, 2018 at 10:02:05PM +0300, Nikita Pettik wrote: > Ephemeral space are extensively used in SQL to store intermediate > results of query processing. To keep things simple, they feature only > one unique index (primary) which covers all fields. However, ephemeral > space can be used to store non-unique entries. In this case, one > additional field added to the end if stored data: > > [field1, ... fieldn, rowid] > > Note that it can't be added to the beginning of tuple since data in > ephemeral space may be kept as sorted. Previously, to generate proper > rowid index_max() was used. However, it is obviously wrong way to do it. > Hence, lets add simple integer counter to memtx space (ephemeral spaces > are valid only for memtx engine) and introduce method in vtab to fetch > next rowid value. > > Needed for #3297 > --- > src/box/blackhole.c | 1 + > src/box/errcode.h | 2 ++ > src/box/memtx_space.c | 17 +++++++++++++++++ > src/box/memtx_space.h | 7 +++++++ > src/box/space.c | 9 +++++++++ > src/box/space.h | 3 +++ > src/box/sysview.c | 1 + > src/box/vinyl.c | 1 + > src/errinj.h | 1 + > test/box/errinj.result | 2 ++ > test/box/misc.result | 1 + > 11 files changed, 45 insertions(+) > > diff --git a/src/box/blackhole.c b/src/box/blackhole.c > index aafbfbf65..e34a2dc4a 100644 > --- a/src/box/blackhole.c > +++ b/src/box/blackhole.c > @@ -118,6 +118,7 @@ static const struct space_vtab blackhole_space_vtab = { > /* .execute_upsert = */ blackhole_space_execute_upsert, > /* .ephemeral_replace = */ generic_space_ephemeral_replace, > /* .ephemeral_delete = */ generic_space_ephemeral_delete, > + /* .ephemeral_rowid_next = */ generic_space_ephemeral_rowid_next, Urgh, I'm starting to think that after all we should tear ephemeral spaces from the generic space class, because they clutter the memtx implementation and never going to work with vinyl anyway, because vinyl has very poor read performance. I think that we should reimplement ephemeral spaces as a completely separate entity. Start with in-memory only design, and when there's a demand make them swappable. May be, we should even consider putting back the original SQLite implementation.