标签:city tinylog Log clickhouse1 TinyLog table id Clickhouse name
目录
应用场景:单表数据量小于100万,查询简单,一次写入多次查询(数据写入阻塞读)
以下日志表引擎性能:由低到高
1. TinyLog
- 单线程不支持并行查询
- 数据按列独立储存
- 创建表
clickhouse1 :)
clickhouse1 :) create table tinylog_table_local on cluster sharding_cluster(
:-] id UInt32,
:-] name String,
:-] city String
:-] ) engine = TinyLog();
CREATE TABLE tinylog_table_local ON CLUSTER sharding_cluster
(
`id` UInt32,
`name` String,
`city` String
)
ENGINE = TinyLog
Query id: 9a90a752-ed12-4efe-b700-b5066c4efe30
┌─host────────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ clickhouse2 │ 9000 │ 0 │ │ 3 │ 0 │
│ clickhouse1 │ 9000 │ 0 │ │ 2 │ 0 │
│ clickhouse3 │ 9000 │ 0 │ │ 1 │ 0 │
│ clickhouse4 │ 9000 │ 0 │ │ 0 │ 0 │
└─────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘
4 rows in set. Elapsed: 0.130 sec.
clickhouse1 :)
clickhouse1 :) create table tinylog_table_all on cluster sharding_cluster(
:-] id UInt32,
:-] name String,
:-] city String
:-] ) engine = Distributed(sharding_cluster, default, tinylog_table_local, id);
CREATE TABLE tinylog_table_all ON CLUSTER sharding_cluster
(
`id` UInt32,
`name` String,
`city` String
)
ENGINE = Distributed(sharding_cluster, default, tinylog_table_local, id)
Query id: 63c200b8-d14d-4b49-ad62-d361bbec1567
┌─host────────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ clickhouse2 │ 9000 │ 0 │ │ 3 │ 0 │
│ clickhouse1 │ 9000 │ 0 │ │ 2 │ 0 │
│ clickhouse3 │ 9000 │ 0 │ │ 1 │ 0 │
│ clickhouse4 │ 9000 │ 0 │ │ 0 │ 0 │
└─────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘
4 rows in set. Elapsed: 0.137 sec.
clickhouse1 :)
- 插入数据
clickhouse1 :)
clickhouse1 :) insert into tinylog_table_all(id, name, city) select number, concat('name', toString(number)), concat('city', toString(number)) from numbers(100);
INSERT INTO tinylog_table_all (id, name, city) SELECT
number,
concat('name', toString(number)),
concat('city', toString(number))
FROM numbers(100)
Query id: b059f2fb-2e49-43be-ab41-59b448ae5c3e
Ok.
0 rows in set. Elapsed: 0.010 sec.
clickhouse1 :)
- 查询数据
clickhouse1 :)
clickhouse1 :) select * from tinylog_table_all limit 3;
SELECT *
FROM tinylog_table_all
LIMIT 3
Query id: 7708a8b3-7829-476f-8154-77b8e76e8fdb
┌─id─┬─name──┬─city──┐
│ 0 │ name0 │ city0 │
│ 4 │ name4 │ city4 │
│ 8 │ name8 │ city8 │
└────┴───────┴───────┘
3 rows in set. Elapsed: 0.007 sec.
clickhouse1 :)
2. StripeLog
- 多线程支持并行查询
- 所有列的数据储存在一个文件
使用方式和TinyLog一样,只是表引擎是StripeLog
3. Log
- 多线程支持并行查询
- 数据按列独立储存
使用方式和TinyLog一样,只是表引擎是Log
标签:city,tinylog,Log,clickhouse1,TinyLog,table,id,Clickhouse,name 来源: https://blog.csdn.net/yy8623977/article/details/119270120
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。