v.21.1New Features

Add optimize_on_insert Setting to Transform INSERTed Data

Add a setting optimize_on_insert. When enabled, do the same transformation for INSERTed block of data as if merge was done on this block (e.g. Replacing, Collapsing, Aggregating...). This setting is enabled by default. This can influence Materialized View and MaterializeMySQL behaviour (see detailed description). This closes #10683. #16954 (Kruglov Pavel).
Introduces the optimize_on_insert setting that applies merge-like transformations (such as Replacing, Collapsing, Aggregating) directly on the inserted data block.

Why it matters

This feature ensures that data inserted into tables undergoes the same kind of optimization as if a merge operation was performed on the block. It improves data consistency and efficiency during insertion, and affects the behavior of Materialized Views and MaterializeMySQL by optimizing data at insert time.

How to use it

The optimize_on_insert setting is enabled by default. To control this behavior, set optimize_on_insert to 1 (enabled) or 0 (disabled) in the server configuration or via session/settings when performing inserts.