From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Thu, 5 Apr 2018 15:30:46 +0300 From: Konstantin Osipov Subject: Re: [PATCH 03/12] alter: do not rebuild secondary indexes on compatible pk changes Message-ID: <20180405123046.GA16501@atlas> References: <18ea755bc3c1a97a90573b35daeac85ecc65a0c5.1522572160.git.vdavydov.dev@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <18ea755bc3c1a97a90573b35daeac85ecc65a0c5.1522572160.git.vdavydov.dev@gmail.com> To: Vladimir Davydov Cc: tarantool-patches@freelists.org List-ID: * Vladimir Davydov [18/04/01 12:08]: Please add a test case. I guess there is no infrastructure to test how well ALTER is optimized. You will need to come up with one. Let's come up with an engine-independent one. The patch itself I've pushed. > If the new cmp_def of a secondary index is compatible with the old one > after the primary key parts have changed, we don't need to rebuild it, > we just need to update its definition. > --- > src/box/alter.cc | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/src/box/alter.cc b/src/box/alter.cc > index 7f130297..174d53fa 100644 > --- a/src/box/alter.cc > +++ b/src/box/alter.cc > @@ -1432,7 +1432,13 @@ alter_space_move_indexes(struct alter_space *alter, uint32_t begin, > old_def->key_def, alter->pk_def); > index_def_update_optionality(new_def, min_field_count); > auto guard = make_scoped_guard([=] { index_def_delete(new_def); }); > - (void) new RebuildIndex(alter, new_def, old_def); > + if (key_part_check_compatibility(old_def->cmp_def->parts, > + old_def->cmp_def->part_count, > + new_def->cmp_def->parts, > + new_def->cmp_def->part_count)) > + (void) new ModifyIndex(alter, new_def, old_def); > + else > + (void) new RebuildIndex(alter, new_def, old_def); > guard.is_active = false; > } > } > -- > 2.11.0 > -- Konstantin Osipov, Moscow, Russia, +7 903 626 22 32 http://tarantool.io - www.twitter.com/kostja_osipov