2021-11-14 15:52:46 +08:00

40 lines
1.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "ClickHouse 表引擎之 Buffer"
date: 2020-10-08T18:08:00+08:00
lastmod: 2020-10-08T18:08:00+08:00
tags: []
categories: ["clickhouse"]
---
## Buffer 表引擎简介
- 只写内存,无持久化存储
- 缓冲高并发写入满足条件时Buffer 表会把数据刷新到目标表
## 创建 Join 引擎表
- 声明
```sql
ENGINE = Buffer(
database,
table,
num_layers,
min_time,
max_time,
min_rows,
max_rows,
min_bytes,
max_bytes
)
```
- database: 目标表所在数据库
- table: 目标表名
- num_layers: 刷新数据到目标表时开启的线程数,官方建议 16
- min_time 和 max_time: 时间条件,单位秒
- min_rows 和 max_rows: 数据行数条件
- min_bytes 和 max_bytes: 数据体量条件,单位字节
- 所有最小阈值都满足时,触发刷新
- 至少一个最大阈值满足时,触发刷新
- 如果一批数据的行数大于 max_rows或体量大于 max_bytes则数据直接写入目标表
- 各线程(num_layers)单独计算刷新规则