表格存储服务 CLOUDTABLE-ClickHouse表引擎概述:VersionedCollapsingMergeTree

时间:2024-10-11 10:34:12

VersionedCollapsingMergeTree

为了解决CollapsingMergeTree表引擎乱序写入导致无法正常折叠(删除)问题,云数据库ClickHouse提供了VersionedCollapsingMergeTree表引擎,在建表语句中新增一列Version,用于在乱序情况下记录状态行与取消行的对应关系。后台Compaction时会将主键相同、Version相同、Sign相反的行折叠(删除)。

  • 建表语句。
    CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER ClickHouse集群名]
    (
        name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1],
        name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2],
        ...
    ) ENGINE = VersionedCollapsingMergeTree(sign, version)
    [PARTITION BY expr]
    [ORDER BY expr]
    [SAMPLE BY expr]
    [SETTINGS name=value, ...]
support.huaweicloud.com/devg-cloudtable/cloudtable_01_0312.html