v.21.7Improvement
Add max_parts_to_merge_at_once Setting to Limit Background Merges
Add merge tree settingmax_parts_to_merge_at_oncewhich limits the number of parts that can be merged in the background at once. Doesn't affectOPTIMIZE FINALquery. Fixes #1820. #24496 (alesapin).
Why it matters
This setting addresses the issue of uncontrolled background merges potentially impacting system resources by allowing users to cap the number of parts merged at once in a merge tree. It helps optimize resource usage and system performance by preventing excessive simultaneous merges.How to use it
To apply this feature, set themax_parts_to_merge_at_once parameter in the merge tree table settings. This limits the background merges to the specified number of parts. Note that this setting does not affect OPTIMIZE FINAL queries, which will merge all parts regardless of this limit.Example:
ALTER TABLE <table_name> MODIFY SETTING max_parts_to_merge_at_once = <number>;