docs/en/sql-reference/statements/alter/apply-patches.md
import BetaBadge from '@theme/badges/BetaBadge';
<BetaBadge/>ALTER TABLE [db.]table [ON CLUSTER cluster] APPLY PATCHES [IN PARTITION partition_id]
The command manually triggers the physical materialization of patch parts created by lightweight UPDATE statements. It forcefully applies pending patches to the data parts by rewriting only the affected columns.
:::note
MergeTree family (including replicated tables).:::tip
Generally, you should not need to use APPLY PATCHES
:::
Patch parts are normally applied automatically during merges when the apply_patches_on_merge setting is enabled (default). However, you may want to manually trigger patch application in these scenarios:
SELECT queriesapply_patches_on_merge is disabled and you want to control when patches are appliedApply all pending patches for a table:
ALTER TABLE my_table APPLY PATCHES;
Apply patches only for a specific partition:
ALTER TABLE my_table APPLY PATCHES IN PARTITION '2024-01';
Combine with other operations:
ALTER TABLE my_table APPLY PATCHES, UPDATE column = value WHERE condition;
You can monitor the progress of patch application using the system.mutations table:
SELECT * FROM system.mutations
WHERE table = 'my_table' AND command LIKE '%APPLY PATCHES%';
UPDATE - Create patch parts with lightweight updatesapply_patches_on_merge setting - Control automatic patch application during merges