mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Added english documentation for extended TTL syntax (#8261)
* Added english documentation for extended TTL syntax. * Update docs/en/operations/table_engines/mergetree.md Co-Authored-By: Ivan Blinkov <github@blinkov.ru> * Added link to multiple volumes. * Update docs/en/operations/table_engines/mergetree.md Co-Authored-By: Ivan Blinkov <github@blinkov.ru> * Update docs/en/operations/table_engines/mergetree.md Co-Authored-By: Ivan Blinkov <github@blinkov.ru> * Update docs/en/operations/table_engines/mergetree.md Co-Authored-By: Ivan Blinkov <github@blinkov.ru> * Changed deletion to removal. * Removed redundant piece of text.
This commit is contained in:
parent
6d58d85579
commit
292c38c514
@ -41,7 +41,7 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster]
|
||||
[ORDER BY expr]
|
||||
[PRIMARY KEY expr]
|
||||
[SAMPLE BY expr]
|
||||
[TTL expr]
|
||||
[TTL expr [DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'], ...]
|
||||
[SETTINGS name=value, ...]
|
||||
```
|
||||
|
||||
@ -70,11 +70,13 @@ For a description of parameters, see the [CREATE query description](../../query_
|
||||
|
||||
If a sampling expression is used, the primary key must contain it. Example: `SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID))`.
|
||||
|
||||
- `TTL` — An expression for setting storage time for rows.
|
||||
- `TTL` — A list of rules specifying storage duration of rows and defining logic of automatic parts movement [between disks and volumes](#table_engine-mergetree-multiple-volumes).
|
||||
|
||||
It must have one `Date` or `DateTime` column as a result. Example:
|
||||
Expression must have one `Date` or `DateTime` column as a result. Example:
|
||||
`TTL date + INTERVAL 1 DAY`
|
||||
|
||||
Type of the rule `DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'` specifies an action to be done with the part if the expression is satisfied (reaches current time): removal of expired rows, moving a part (if expression is satisfied for all rows in a part) to specified disk (`TO DISK 'xxx'`) or to volume (`TO VOLUME 'xxx'`). Default type of the rule is removal (`DELETE`). List of multiple rules can specified, but there should be no more than one `DELETE` rule.
|
||||
|
||||
For more details, see [TTL for columns and tables](#table_engine-mergetree-ttl)
|
||||
|
||||
- `SETTINGS` — Additional parameters that control the behavior of the `MergeTree`:
|
||||
@ -371,9 +373,11 @@ Reading from a table is automatically parallelized.
|
||||
|
||||
Determines the lifetime of values.
|
||||
|
||||
The `TTL` clause can be set for the whole table and for each individual column. If both `TTL` are set, ClickHouse uses that `TTL` which expires earlier.
|
||||
The `TTL` clause can be set for the whole table and for each individual column. Table-level TTL can also specify logic of automatic move of data between disks and volumes.
|
||||
|
||||
To define the lifetime of data, use expression evaluating to [Date](../../data_types/date.md) or [DateTime](../../data_types/datetime.md) data type, for example:
|
||||
Expressions must evaluate to [Date](../../data_types/date.md) or [DateTime](../../data_types/datetime.md) data type.
|
||||
|
||||
Example:
|
||||
|
||||
```sql
|
||||
TTL time_column
|
||||
@ -428,7 +432,17 @@ ALTER TABLE example_table
|
||||
|
||||
**Table TTL**
|
||||
|
||||
When data in a table expires, ClickHouse deletes all corresponding rows.
|
||||
Table can have an expression for removal of expired rows, and multiple expressions for automatic move of parts between [disks or volumes](#table_engine-mergetree-multiple-volumes). When rows in the table expire, ClickHouse deletes all corresponding rows. For parts moving feature, all rows of a part must satisfy the movement expression criteria.
|
||||
|
||||
```sql
|
||||
TTL expr [DELETE|TO DISK 'aaa'|TO VOLUME 'bbb'], ...
|
||||
```
|
||||
|
||||
Type of TTL rule may follow each TTL expression. It affects an action which is to be done once the expression is satisfied (reaches current time):
|
||||
|
||||
- `DELETE` - delete expired rows (default action);
|
||||
- `TO DISK 'aaa'` - move part to the disk `aaa`;
|
||||
- `TO VOLUME 'bbb'` - move part to the disk `bbb`.
|
||||
|
||||
Examples:
|
||||
|
||||
@ -443,7 +457,9 @@ CREATE TABLE example_table
|
||||
ENGINE = MergeTree
|
||||
PARTITION BY toYYYYMM(d)
|
||||
ORDER BY d
|
||||
TTL d + INTERVAL 1 MONTH;
|
||||
TTL d + INTERVAL 1 MONTH [DELETE],
|
||||
d + INTERVAL 1 WEEK TO VOLUME 'aaa',
|
||||
d + INTERVAL 2 WEEK TO DISK 'bbb';
|
||||
```
|
||||
|
||||
Altering TTL of the table
|
||||
|
Loading…
Reference in New Issue
Block a user