Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

using LowCardinality for performance table

Blue Mouse566cdf2ee6ba
diff --git a/migrations/clickhouse/2023_04_25.js b/migrations/clickhouse/2023_04_25.js
index a9aac23b8..c8b201a66 100644
--- a/migrations/clickhouse/2023_04_25.js
+++ b/migrations/clickhouse/2023_04_25.js
@@ -58,6 +58,35 @@ const queries = [
`DROP TABLE ${dbName}.customEV`,
`RENAME TABLE ${dbName}.customEV_temp TO ${dbName}.customEV`,
+
+ // Performance -> LowCardinality
+ `DROP TABLE IF EXISTS ${dbName}.performance_temp`,
+ `CREATE TABLE IF NOT EXISTS ${dbName}.performance_temp
+ (
+ pid FixedString(12),
+ pg Nullable(String),
+ dv LowCardinality(Nullable(String)),
+ br LowCardinality(Nullable(String)),
+ cc Nullable(FixedString(2)),
+ dns Nullable(UInt32),
+ tls Nullable(UInt32),
+ conn Nullable(UInt32),
+ response Nullable(UInt32),
+ render Nullable(UInt32),
+ domLoad Nullable(UInt32),
+ pageLoad Nullable(UInt32),
+ ttfb Nullable(UInt32),
+ created DateTime
+ )
+ ENGINE = MergeTree()
+ PARTITION BY toYYYYMM(created)
+ ORDER BY (pid, created);`,
+
+ `INSERT INTO ${dbName}.performance_temp (pid, pg, dv, br, cc, dns, tls, conn, response, render, domLoad, pageLoad, ttfb, created)
+ SELECT pid, pg, dv, br, cc, dns, tls, conn, response, render, domLoad, pageLoad, ttfb, created FROM ${dbName}.performance`,
+
+ `DROP TABLE ${dbName}.performance`,
+ `RENAME TABLE ${dbName}.performance_temp TO ${dbName}.performance`,
]
queriesRunner(queries)
diff --git a/migrations/clickhouse/initialise_database.js b/migrations/clickhouse/initialise_database.js
index f273158e5..8a63e32be 100644
--- a/migrations/clickhouse/initialise_database.js
+++ b/migrations/clickhouse/initialise_database.js
@@ -55,8 +55,8 @@ const CLICKHOUSE_INIT_QUERIES = [
(
pid FixedString(12),
pg Nullable(String),
- dv Nullable(String),
- br Nullable(String),
+ dv LowCardinality(Nullable(String)),
+ br LowCardinality(Nullable(String)),
cc Nullable(FixedString(2)),
dns Nullable(UInt32),
tls Nullable(UInt32),
diff --git a/src/common/constants.ts b/src/common/constants.ts
index 8b661614a..e308b495f 100644
--- a/src/common/constants.ts
+++ b/src/common/constants.ts
@@ -102,8 +102,8 @@ const CLICKHOUSE_INIT_QUERIES = [
(
pid FixedString(12),
pg Nullable(String),
- dv Nullable(String),
- br Nullable(String),
+ dv LowCardinality(Nullable(String)),
+ br LowCardinality(Nullable(String)),
cc Nullable(FixedString(2)),
dns Nullable(UInt32),
tls Nullable(UInt32),