简体   繁体   中英

How to change order of composed primary key in clickhouse efficiently

I have a table with schema

CREATE TABLE traffic ( date Date, val1 UInt64, 'val2' UInt64 ... ) ENGINE = ReplicatedMergeTree(date, (val1, val2), 8192);

the partition key is date here. I want to change the order from (val1, val2) to (val2, val1)

I only way i know is rename this table to someting(traffic_temp), create table with name 'trafic' and ordering (val2, val1) and copy the data from temp to traffic and then delete the temp table.

But the dataset is huge, is there any better way to do it??

No other way. Only insert select .

You can use clickhouse-copier but it does the same insert select

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM