Clickhouse中Buffer表的参数如何选择?

问题描述 投票:0回答:1

我想创建一个缓冲表来减少小插入的次数,但我不明白如何为表选择参数? 例如,我希望缓冲表每 4 小时或者行数达到 10000 时将数据刷新到目标表。但是还有其他参数,例如 min\max bytes 和 num_layers。

buffer clickhouse
1个回答
0
投票

您需要将

max_bytes
参数设置为足够高的值,以便在 100,000 行或 4 小时之前不会触发刷新。

num_layers
实际上是缓冲区的数量 - 如果您快速插入大量数据以并行化工作,这很有用......但在您的用例中,这似乎不是必需的。您应该将
num_layers
设置为 1。

换句话说:

CREATE TABLE my_buffer_table 
AS my_destination_table 
ENGINE = Buffer(
    default, --db name
    my_destination_table, --table name
    1, --num_layers
    60, --min_seconds (put whatever you want here)
    14400, --max_seconds (4 hours)
    1000, --min rows (put whatever you want here)
    100000, --100,000 max rows
    100, --min bytes (something small)
    500000000 --max bytes (you need something smart here)
);

因为您不希望最后一个参数触发刷新,所以请确保该值大于 100,000 行数据。

© www.soinside.com 2019 - 2024. All rights reserved.