From 61dfa1391e80558e1939987562e2f4ce95ba33d3 Mon Sep 17 00:00:00 2001 From: Francis Cao Date: Thu, 1 Aug 2024 15:34:35 -0700 Subject: [PATCH] add projection code --- db/clickhouse/schema.sql | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/db/clickhouse/schema.sql b/db/clickhouse/schema.sql index aadc5402..8bdcfc0b 100644 --- a/db/clickhouse/schema.sql +++ b/db/clickhouse/schema.sql @@ -170,4 +170,19 @@ GROUP BY website_id, subdivision1, city, event_type, - timestamp); \ No newline at end of file + timestamp); + +-- projections +ALTER TABLE umami.website_event +ADD PROJECTION website_event_url_path_projection ( +SELECT * ORDER BY toStartOfDay(created_at), website_id, url_path, created_at +); + +ALTER TABLE umami.website_event MATERIALIZE PROJECTION website_event_url_path_projection; + +ALTER TABLE umami.website_event +ADD PROJECTION website_event_referrer_domain_projection ( +SELECT * ORDER BY toStartOfDay(created_at), website_id, referrer_domain, created_at +); + +ALTER TABLE umami.website_event MATERIALIZE PROJECTION website_event_referrer_domain_projection;