I have a ClickHouse schema as following, MergeTree is in question:
(
hotel String,
staff_member String,
task_number Float64,
date DateTime
)
PRIMARY KEY (hotel, date)
ORDER BY (hotel, date)
My aggregation is as following:
SELECT
staff_member,
sum(task_number)
FROM ...
WHERE
hotel = {hotel}
AND date >= {first_date}
AND date <= {top_date}
GROUP BY staff_member
Basically, I'm aggregating the number of tasks of a staff member over a period of time, but the aggregation is kind of slow. I have a feeling the primary key is off and I need to rework it.
First that comes to mind would be to change the key to (hotel, staff_member, date)
since I'm grouping by the staff_member
I'm thankful for any help!