mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 11:02:08 +00:00
add text
This commit is contained in:
parent
c68f0477c6
commit
00bb72735e
@ -2592,4 +2592,58 @@ Possible values:
|
|||||||
|
|
||||||
Default value: `16`.
|
Default value: `16`.
|
||||||
|
|
||||||
|
## optimize_on_insert {#optimize-on-insert}
|
||||||
|
|
||||||
|
Enables or disables data transformation before the insertion, as if merge was done on this block (according to table engine).
|
||||||
|
|
||||||
|
Possible values:
|
||||||
|
|
||||||
|
- 0 — Disabled.
|
||||||
|
- 1 — Enabled.
|
||||||
|
|
||||||
|
Default value: 1.
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
|
||||||
|
The difference between enabled and disabled:
|
||||||
|
|
||||||
|
Query:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SET optimize_on_insert = 1;
|
||||||
|
|
||||||
|
CREATE TABLE test1 (`FirstTable` UInt32) ENGINE = ReplacingMergeTree ORDER BY FirstTable;
|
||||||
|
|
||||||
|
INSERT INTO test1 SELECT number % 2 FROM numbers(5);
|
||||||
|
|
||||||
|
SELECT * FROM test1;
|
||||||
|
|
||||||
|
SET optimize_on_insert = 0;
|
||||||
|
|
||||||
|
CREATE TABLE test2 (`SecondTable` UInt32) ENGINE = ReplacingMergeTree ORDER BY SecondTable;
|
||||||
|
|
||||||
|
INSERT INTO test2 SELECT number % 2 FROM numbers(5);
|
||||||
|
|
||||||
|
SELECT * FROM test2;
|
||||||
|
```
|
||||||
|
|
||||||
|
Result:
|
||||||
|
|
||||||
|
``` text
|
||||||
|
┌─FirstTable─┐
|
||||||
|
│ 0 │
|
||||||
|
│ 1 │
|
||||||
|
└────────────┘
|
||||||
|
|
||||||
|
┌─SecondTable─┐
|
||||||
|
│ 0 │
|
||||||
|
│ 0 │
|
||||||
|
│ 0 │
|
||||||
|
│ 1 │
|
||||||
|
│ 1 │
|
||||||
|
└─────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that this setting influences [Materialized view](../../sql-reference/statements/create/view.md#materialized) and [MaterializeMySQL](../../engines/database-engines/materialize-mysql.md) behaviour.
|
||||||
|
|
||||||
[Original article](https://clickhouse.tech/docs/en/operations/settings/settings/) <!-- hide -->
|
[Original article](https://clickhouse.tech/docs/en/operations/settings/settings/) <!-- hide -->
|
||||||
|
Loading…
Reference in New Issue
Block a user