v.25.12New Feature
Index behavior on ALTER
Add a MergeTree setting alter_column_secondary_index_mode to control what to do with indices during mutations. Possible values: throw, drop, rebuild, and compatibility. Closes #77797. #89335 (Raúl Marín).Why it matters
This feature allows users to specify how secondary indices are managed when columns are altered via mutations. It addresses ambiguity and potential errors by providing options to throw an error, drop the indices, rebuild them, or maintain backward compatibility, thereby improving mutation flexibility and stability.How to use it
Users can configure the behavior of secondary indices during column mutations by setting thealter_column_secondary_index_mode in the MergeTree table settings. The setting accepts the following values:-
throw: Raises an error if the mutation affects secondary indices.-
drop: Drops secondary indices when columns are mutated.-
rebuild: Rebuilds the secondary indices after mutation.-
compatibility: Maintains previous default behavior for backward compatibility.Example syntax to set the mode:
ALTER TABLE <table_name> MODIFY SETTING alter_column_secondary_index_mode = '<mode>'