I’m trying to create a partitioned table in Clickhouse with:
CREATE TABLE IF NOT EXISTS new_table (
logging_day Date,
sensor_name String,
ts DateTime
ts_hour DateTime MATERIALIZED toStartOfHour(ts),
)
ENGINE=MergeTree()
PARTITION BY logging_day
ORDER BY (sensor_name, ts_hour, ts)
PRIMARY KEY (sensor_name, ts_hour);
The table is partitioned by logging_day
. From query performance perspective, does it still need be added to the ORDER BY
or PRIMARY KEY
lists like:
ORDER BY (logging_day, sensor_name, ts_hour, ts)
PRIMARY KEY (logging_day, sensor_name, ts_hour);
Which way will make the WHERE
filtered queries faster, with or without the partition key in the lists? Thanks.