[PATCH 03/12] alter: do not rebuild secondary indexes on compatible pk changes

Konstantin Osipov kostja at tarantool.org
Thu Apr 5 15:30:46 MSK 2018


* Vladimir Davydov <vdavydov.dev at gmail.com> [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



More information about the Tarantool-patches mailing list