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

Vladimir Davydov vdavydov.dev at gmail.com
Sun Apr 1 12:05:30 MSK 2018


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




More information about the Tarantool-patches mailing list