字段优化
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);