mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-07 08:03:15 +00:00
4ec7821fec
* enbaskakova-DOCSUP-652 (#101)
* "docs(orNull&orDefault): Functions 'orNull&orDefault' have been edited"
* "docs(orNull&orDefault): Functions 'orNull&orDefault' have been edited"
* "docs(orNull&orDefault): Functions 'orNull&orDefault' have been edited"
* Update docs/en/sql_reference/aggregate_functions/combinators.md
Co-Authored-By: BayoNet <da-daos@yandex.ru>
* Update docs/en/sql_reference/aggregate_functions/combinators.md
Co-Authored-By: BayoNet <da-daos@yandex.ru>
* Update docs/en/sql_reference/aggregate_functions/combinators.md
Co-Authored-By: BayoNet <da-daos@yandex.ru>
* Update docs/en/sql_reference/aggregate_functions/combinators.md
Co-Authored-By: BayoNet <da-daos@yandex.ru>
* Update docs/en/sql_reference/aggregate_functions/combinators.md
Co-Authored-By: BayoNet <da-daos@yandex.ru>
* "docs(orNull&orDefault): Functions 'orNull&orDefault' have been edited"
* "docs(orNull&orDefault): Functions 'orNull&orDefault' have been edited"
* "docs(orNull&orDefault): Functions 'orNull&orDefault' have been edited"
Co-authored-by: elenbaskakova <elenbaskakova@yandex-team.ru>
Co-authored-by: BayoNet <da-daos@yandex.ru>
* Revert "enbaskakova-DOCSUP-652 (#101)" (#107)
This reverts commit 639fee7610
.
* CLICKHOUSEDOCS-624: Fixed en
* CLICKHOUSEDOCS-624: Fixed RU.
* CLICKHOUSEDOCS-624: Fixed ES and FR.
* CLICKHOUSEDOCS-624: Fixed JA and TR
* CLICKHOUSEDOCS-624: Fixed FA.
* CLICKHOUSEDOCS-624: Fixed ZH.
* Update docs/tools/test.py
Co-authored-by: Ivan Blinkov <github@blinkov.ru>
* Update docs/tools/test.py
Co-authored-by: Ivan Blinkov <github@blinkov.ru>
Co-authored-by: elenaspb2019 <47083263+elenaspb2019@users.noreply.github.com>
Co-authored-by: elenbaskakova <elenbaskakova@yandex-team.ru>
Co-authored-by: Sergei Shtykov <bayonet@yandex-team.ru>
Co-authored-by: Ivan Blinkov <github@blinkov.ru>
3.9 KiB
3.9 KiB
StripeLog
该引擎属于日志引擎系列。请在日志引擎系列文章中查看引擎的共同属性和差异。
在你需要写入许多小数据量(小于一百万行)的表的场景下使用这个引擎。
建表
CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster]
(
column1_name [type1] [DEFAULT|MATERIALIZED|ALIAS expr1],
column2_name [type2] [DEFAULT|MATERIALIZED|ALIAS expr2],
...
) ENGINE = StripeLog
查看建表请求的详细说明。
写数据
StripeLog
引擎将所有列存储在一个文件中。对每一次 Insert
请求,ClickHouse 将数据块追加在表文件的末尾,逐列写入。
ClickHouse 为每张表写入以下文件:
data.bin
— 数据文件。index.mrk
— 带标记的文件。标记包含了已插入的每个数据块中每列的偏移量。
StripeLog
引擎不支持 ALTER UPDATE
和 ALTER DELETE
操作。
读数据
带标记的文件使得 ClickHouse 可以并行的读取数据。这意味着 SELECT
请求返回行的顺序是不可预测的。使用 ORDER BY
子句对行进行排序。
使用示例
建表:
CREATE TABLE stripe_log_table
(
timestamp DateTime,
message_type String,
message String
)
ENGINE = StripeLog
插入数据:
INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The first regular message')
INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The second regular message'),(now(),'WARNING','The first warning message')
我们使用两次 INSERT
请求从而在 data.bin
文件中创建两个数据块。
ClickHouse 在查询数据时使用多线程。每个线程读取单独的数据块并在完成后独立的返回结果行。这样的结果是,大多数情况下,输出中块的顺序和输入时相应块的顺序是不同的。例如:
SELECT * FROM stripe_log_table
┌───────────timestamp─┬─message_type─┬─message────────────────────┐
│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │
│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │
└─────────────────────┴──────────────┴────────────────────────────┘
┌───────────timestamp─┬─message_type─┬─message───────────────────┐
│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │
└─────────────────────┴──────────────┴───────────────────────────┘
对结果排序(默认增序):
SELECT * FROM stripe_log_table ORDER BY timestamp
┌───────────timestamp─┬─message_type─┬─message────────────────────┐
│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │
│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │
│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │
└─────────────────────┴──────────────┴────────────────────────────┘