Skip to content

Commit

Permalink
upd: type_id, codecs
Browse files Browse the repository at this point in the history
  • Loading branch information
akvlad committed Nov 16, 2023
1 parent de97276 commit 210161e
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/db/maintain/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ module.exports.profiles = [
payload_type LowCardinality(String) CODEC(ZSTD(1)),
payload String CODEC(ZSTD(1))
) Engine {{MergeTree}}()
ORDER BY (timestamp_ns)
ORDER BY (type_id, timestamp_ns)
PARTITION BY toDate(FROM_UNIXTIME(intDiv(timestamp_ns, 1000000000)))`,

`CREATE MATERIALIZED VIEW IF NOT EXISTS profiles_mv {{{OnCluster}}} TO profiles AS
Expand All @@ -277,34 +277,38 @@ module.exports.profiles = [
FROM profiles_input`,

`CREATE TABLE IF NOT EXISTS profiles_series {{{OnCluster}}} (
date Date,
fingerprint UInt64 CODEC(DoubleDelta, ZSTD(1)),
date Date CODEC(ZSTD(1)),
type_id LowCardinality(String) CODEC(ZSTD(1)),
fingerprint UInt64 CODEC(DoubleDelta, ZSTD(1)),
tags Array(Tuple(String, String)) CODEC(ZSTD(1)),
) Engine {{ReplacingMergeTree}}()
ORDER BY (date, fingerprint)
ORDER BY (date, type_id, fingerprint)
PARTITION BY date`,

`CREATE MATERIALIZED VIEW IF NOT EXISTS profiles_series_mv {{{OnCluster}}} TO profiles_series AS
SELECT
toDate(intDiv(timestamp_ns, 1000000000)) as date,
type_id,
fingerprint,
tags
FROM profiles`,

`CREATE TABLE IF NOT EXISTS profiles_series_gin {{{OnCluster}}} (
date Date,
key String,
val String,
date Date CODEC(ZSTD(1)),
key String CODEC(ZSTD(1)),
val String CODEC(ZSTD(1)),
type_id LowCardinality(String) CODEC(ZSTD(1)),
fingerprint UInt64 CODEC(DoubleDelta, ZSTD(1)),
) Engine {{ReplacingMergeTree}}()
ORDER BY (date, key, val, fingerprint)
ORDER BY (date, key, val, type_id, fingerprint)
PARTITION BY date`,

`CREATE MATERIALIZED VIEW IF NOT EXISTS profiles_series_gin_mv {{{OnCluster}}} TO profiles_series_gin AS
SELECT
date,
kv.1 as key,
kv.2 as val,
type_id,
fingerprint,
FROM profiles_series ARRAY JOIN tags as kv`,

Expand Down

0 comments on commit 210161e

Please sign in to comment.