SummingMergeTree按元组分区

时间:2018-06-27 09:06:15

标签: optimization tuples clickhouse

尝试创建由元组分区的SummingMergeTree,如下所示:

CREATE TABLE partitioned_by_tuple(d Date, x UInt8, w String, y UInt8) ENGINE SummingMergeTree (y) PARTITION BY (d, x) ORDER BY (d, x, w);

将数据插入表中

┌──────────d─┬─x─┬─w─────┬─y─┐
│ 2000-01-02 │ 1 │ first │ 3 │
└────────────┴───┴───────┴───┘
┌──────────d─┬─x─┬─w─────┬─y─┐
│ 2000-01-01 │ 2 │ first │ 2 │
└────────────┴───┴───────┴───┘
┌──────────d─┬─x─┬─w─────┬─y─┐
│ 2000-01-01 │ 1 │ first │ 1 │
│ 2000-01-01 │ 1 │ first │ 2 │
└────────────┴───┴───────┴───┘

尝试优化表格:

OPTIMIZE TABLE partitioned_by_tuple;

并希望像这样:

┌──────────d─┬─x─┬─w─────┬─y─┐
│ 2000-01-02 │ 1 │ first │ 3 │
└────────────┴───┴───────┴───┘
┌──────────d─┬─x─┬─w─────┬─y─┐
│ 2000-01-01 │ 2 │ first │ 2 │
└────────────┴───┴───────┴───┘
┌──────────d─┬─x─┬─w─────┬─y─┐
│ 2000-01-01 │ 1 │ first │ 3 │
└────────────┴───┴───────┴───┘

但是表在优化后不会更改。

我在做什么错了?

1 个答案:

答案 0 :(得分:0)

根据https://clickhouse.yandex/docs/en/single/#optimize

  

如果您指定FINAL,即使所有数据都已经在一个部分中,也会执行优化。

您需要在末尾指定FINAL,以强制将优化内容嵌入到一个部分中。

编辑:

此PR https://github.com/yandex/ClickHouse/pull/2599之后,OPTIMIZE将能够使用FINAL合并所有部分。

现在已合并。

相关问题