字段优化
LowCarditality是将源字符串等类型的数据转换为字典值的一种数据处理方法,当源字符串很长且去重后值的数量不是很大时(低于 1000 万),它的效果最佳。
1、查看设置
select * from system.settings where name='allow_suspicious_low_cardinality_types'
2、建表
CREATE TABLE test
(
`id` UInt16,
`brand` LowCardinality(String)
)
ENGINE = MergeTree()
ORDER BY id
3、直接修改
ALTER TABLE dwd_event_local on cluster default_cluster MODIFY COLUMN business LowCardinality(String);
ALTER TABLE dwd_event_local on cluster default_cluster MODIFY COLUMN channel LowCardinality(String);
ALTER TABLE dwd_event_local on cluster default_cluster MODIFY COLUMN brand LowCardinality(String);
本文介绍了如何通过LowCardinality技术优化字符串数据,包括查看设置方法、创建表的示例以及ALTER TABLE操作,重点在于适用于值数量少于1000万的场景.
1776

被折叠的 条评论
为什么被折叠?



