Delete Mutations
Delete mutations refers to ALTER
queries that manipulate table data through delete. Most notably they are queries like ALTER TABLE DELETE
, etc. Performing such queries will produce new mutated versions of the data parts. This means that such statements would trigger a rewrite of whole data parts for all data that was inserted before the mutation, translating to a large amount of write requests.
For deletes, you can avoid these large amounts of write requests by using specialised table engines like ReplacingMergeTree or CollapsingMergeTree instead of the default MergeTree table engine.
ALTER TABLE ... DELETE Statement
ALTER TABLE [db.]table [ON CLUSTER cluster] DELETE WHERE filter_expr
Deletes data matching the specified filtering expression. Implemented as a mutation.
The ALTER TABLE
prefix makes this syntax different from most other systems supporting SQL. It is intended to signify that unlike similar queries in OLTP databases this is a heavy operation not designed for frequent use. ALTER TABLE
is considered a heavyweight operation that requires the underlying data to be merged before it is deleted. For MergeTree tables, consider using the DELETE FROM
query, which performs a lightweight delete and can be considerably faster.
The filter_expr
must be of type UInt8
. The query deletes rows in the table for which this expression takes a non-zero value.
One query can contain several commands separated by commas.
The synchronicity of the query processing is defined by the mutations_sync setting. By default, it is asynchronous.
See also