Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(metrics): index the point time range of metrics4_samples (#105380)

Frank Hamand20f9d3187e72
diff --git a/posthog/clickhouse/hcl/golden/dev/logs.hcl b/posthog/clickhouse/hcl/golden/dev/logs.hcl
index ff2ed1de78a6..3b800bfc5f05 100644
--- a/posthog/clickhouse/hcl/golden/dev/logs.hcl
+++ b/posthog/clickhouse/hcl/golden/dev/logs.hcl
@@ -2140,6 +2140,14 @@ SQL
column "trace_flags_arr" {
type = "SimpleAggregateFunction(groupArrayArray(10000), Array(Int32))"
}
+ column "timestamp_min" {
+ type = "DateTime64(6)"
+ alias = "arrayMin(timestamp_arr)"
+ }
+ column "timestamp_max" {
+ type = "DateTime64(6)"
+ alias = "arrayMax(timestamp_arr)"
+ }
index "idx_metric_type_set" {
expr = "metric_type"
type = "set(10)"
@@ -2155,6 +2163,16 @@ SQL
type = "bloom_filter(0.01)"
granularity = 1
}
+ index "idx_timestamp_min_minmax" {
+ expr = "timestamp_min"
+ type = "minmax"
+ granularity = 1
+ }
+ index "idx_timestamp_max_minmax" {
+ expr = "timestamp_max"
+ type = "minmax"
+ granularity = 1
+ }
engine "replicated_aggregating_merge_tree" {
zoo_path = "/clickhouse/tables/noshard/posthog.metrics4_samples"
replica_name = "{replica}-{shard}"
diff --git a/posthog/clickhouse/hcl/golden/local-multi/logs.hcl b/posthog/clickhouse/hcl/golden/local-multi/logs.hcl
index ee96328e0c0f..7468a2e6ed25 100644
--- a/posthog/clickhouse/hcl/golden/local-multi/logs.hcl
+++ b/posthog/clickhouse/hcl/golden/local-multi/logs.hcl
@@ -2714,6 +2714,14 @@ SQL
column "trace_flags_arr" {
type = "SimpleAggregateFunction(groupArrayArray(10000), Array(Int32))"
}
+ column "timestamp_min" {
+ type = "DateTime64(6)"
+ alias = "arrayMin(timestamp_arr)"
+ }
+ column "timestamp_max" {
+ type = "DateTime64(6)"
+ alias = "arrayMax(timestamp_arr)"
+ }
index "idx_metric_type_set" {
expr = "metric_type"
type = "set(10)"
@@ -2729,6 +2737,16 @@ SQL
type = "bloom_filter(0.01)"
granularity = 1
}
+ index "idx_timestamp_min_minmax" {
+ expr = "timestamp_min"
+ type = "minmax"
+ granularity = 1
+ }
+ index "idx_timestamp_max_minmax" {
+ expr = "timestamp_max"
+ type = "minmax"
+ granularity = 1
+ }
engine "replicated_aggregating_merge_tree" {
zoo_path = "/clickhouse/tables/noshard/posthog.metrics4_samples"
replica_name = "{replica}-{shard}"
diff --git a/posthog/clickhouse/hcl/golden/local-single/all.hcl b/posthog/clickhouse/hcl/golden/local-single/all.hcl
index eb986bfb1c60..3035e4ca459c 100644
--- a/posthog/clickhouse/hcl/golden/local-single/all.hcl
+++ b/posthog/clickhouse/hcl/golden/local-single/all.hcl
@@ -7768,6 +7768,14 @@ SQL
column "trace_flags_arr" {
type = "SimpleAggregateFunction(groupArrayArray(10000), Array(Int32))"
}
+ column "timestamp_min" {
+ type = "DateTime64(6)"
+ alias = "arrayMin(timestamp_arr)"
+ }
+ column "timestamp_max" {
+ type = "DateTime64(6)"
+ alias = "arrayMax(timestamp_arr)"
+ }
index "idx_metric_type_set" {
expr = "metric_type"
type = "set(10)"
@@ -7783,6 +7791,16 @@ SQL
type = "bloom_filter(0.01)"
granularity = 1
}
+ index "idx_timestamp_min_minmax" {
+ expr = "timestamp_min"
+ type = "minmax"
+ granularity = 1
+ }
+ index "idx_timestamp_max_minmax" {
+ expr = "timestamp_max"
+ type = "minmax"
+ granularity = 1
+ }
engine "replicated_aggregating_merge_tree" {
zoo_path = "/clickhouse/tables/noshard/posthog.metrics4_samples"
replica_name = "{replica}-{shard}"
diff --git a/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl b/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl
index 50bb0433f10e..0397e61e4f63 100644
--- a/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl
+++ b/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl
@@ -2300,6 +2300,14 @@ SQL
column "trace_flags_arr" {
type = "SimpleAggregateFunction(groupArrayArray(10000), Array(Int32))"
}
+ column "timestamp_min" {
+ type = "DateTime64(6)"
+ alias = "arrayMin(timestamp_arr)"
+ }
+ column "timestamp_max" {
+ type = "DateTime64(6)"
+ alias = "arrayMax(timestamp_arr)"
+ }
index "idx_metric_type_set" {
expr = "metric_type"
type = "set(10)"
@@ -2315,6 +2323,16 @@ SQL
type = "bloom_filter(0.01)"
granularity = 1
}
+ index "idx_timestamp_min_minmax" {
+ expr = "timestamp_min"
+ type = "minmax"
+ granularity = 1
+ }
+ index "idx_timestamp_max_minmax" {
+ expr = "timestamp_max"
+ type = "minmax"
+ granularity = 1
+ }
engine "replicated_aggregating_merge_tree" {
zoo_path = "/clickhouse/tables/noshard/posthog.metrics4_samples"
replica_name = "{replica}-{shard}"
diff --git a/posthog/clickhouse/hcl/golden/prod-us/logs.hcl b/posthog/clickhouse/hcl/golden/prod-us/logs.hcl
index 3fb9334acac9..9d0df8ebe1c5 100644
--- a/posthog/clickhouse/hcl/golden/prod-us/logs.hcl
+++ b/posthog/clickhouse/hcl/golden/prod-us/logs.hcl
@@ -2300,6 +2300,14 @@ SQL
column "trace_flags_arr" {
type = "SimpleAggregateFunction(groupArrayArray(10000), Array(Int32))"
}
+ column "timestamp_min" {
+ type = "DateTime64(6)"
+ alias = "arrayMin(timestamp_arr)"
+ }
+ column "timestamp_max" {
+ type = "DateTime64(6)"
+ alias = "arrayMax(timestamp_arr)"
+ }
index "idx_metric_type_set" {
expr = "metric_type"
type = "set(10)"
@@ -2315,6 +2323,16 @@ SQL
type = "bloom_filter(0.01)"
granularity = 1
}
+ index "idx_timestamp_min_minmax" {
+ expr = "timestamp_min"
+ type = "minmax"
+ granularity = 1
+ }
+ index "idx_timestamp_max_minmax" {
+ expr = "timestamp_max"
+ type = "minmax"
+ granularity = 1
+ }
engine "replicated_aggregating_merge_tree" {
zoo_path = "/clickhouse/tables/noshard/posthog.metrics4_samples"
replica_name = "{replica}-{shard}"
diff --git a/posthog/clickhouse/hcl/roles/logs/metrics/metrics4.hcl b/posthog/clickhouse/hcl/roles/logs/metrics/metrics4.hcl
index ca4b54488b60..90576d50a012 100644
--- a/posthog/clickhouse/hcl/roles/logs/metrics/metrics4.hcl
+++ b/posthog/clickhouse/hcl/roles/logs/metrics/metrics4.hcl
@@ -176,6 +176,14 @@ database "posthog" {
column "trace_flags_arr" {
type = "SimpleAggregateFunction(groupArrayArray(10000), Array(Int32))"
}
+ column "timestamp_min" {
+ type = "DateTime64(6)"
+ alias = "arrayMin(timestamp_arr)"
+ }
+ column "timestamp_max" {
+ type = "DateTime64(6)"
+ alias = "arrayMax(timestamp_arr)"
+ }
index "idx_metric_type_set" {
expr = "metric_type"
type = "set(10)"
@@ -191,6 +199,16 @@ database "posthog" {
type = "bloom_filter(0.01)"
granularity = 1
}
+ index "idx_timestamp_min_minmax" {
+ expr = "timestamp_min"
+ type = "minmax"
+ granularity = 1
+ }
+ index "idx_timestamp_max_minmax" {
+ expr = "timestamp_max"
+ type = "minmax"
+ granularity = 1
+ }
engine "replicated_aggregating_merge_tree" {
zoo_path = "/clickhouse/tables/noshard/posthog.metrics4_samples"
replica_name = "{replica}-{shard}"
diff --git a/posthog/clickhouse/hcl/sql/dev/logs.sql b/posthog/clickhouse/hcl/sql/dev/logs.sql
index c68e8deccad2..bda8755f437b 100644
--- a/posthog/clickhouse/hcl/sql/dev/logs.sql
+++ b/posthog/clickhouse/hcl/sql/dev/logs.sql
@@ -548,9 +548,13 @@ CREATE TABLE posthog.metrics4_samples (
trace_id_arr SimpleAggregateFunction(groupArrayArray(10000), Array(String)),
span_id_arr SimpleAggregateFunction(groupArrayArray(10000), Array(String)),
trace_flags_arr SimpleAggregateFunction(groupArrayArray(10000), Array(Int32)),
+ timestamp_min DateTime64(6) ALIAS arrayMin(timestamp_arr),
+ timestamp_max DateTime64(6) ALIAS arrayMax(timestamp_arr),
INDEX idx_metric_type_set metric_type TYPE set(10) GRANULARITY 1,
INDEX idx_time_bucket_minmax time_bucket TYPE minmax GRANULARITY 1,
- INDEX idx_trace_id_bf trace_id_arr TYPE bloom_filter(0.01) GRANULARITY 1
+ INDEX idx_trace_id_bf trace_id_arr TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX idx_timestamp_min_minmax timestamp_min TYPE minmax GRANULARITY 1,
+ INDEX idx_timestamp_max_minmax timestamp_max TYPE minmax GRANULARITY 1
) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.metrics4_samples', '{replica}-{shard}') ORDER BY (team_id, metric_name, time_bucket, series_fingerprint) PARTITION BY original_expiry_date TTL original_expiry_date SETTINGS index_granularity = 128, ttl_only_drop_parts = 1;
CREATE TABLE posthog.metrics4_series (
team_id Int32,
diff --git a/posthog/clickhouse/hcl/sql/local-multi/logs.sql b/posthog/clickhouse/hcl/sql/local-multi/logs.sql
index cb61c9e45048..a2741ff74ce7 100644
--- a/posthog/clickhouse/hcl/sql/local-multi/logs.sql
+++ b/posthog/clickhouse/hcl/sql/local-multi/logs.sql
@@ -662,9 +662,13 @@ CREATE TABLE posthog.metrics4_samples (
trace_id_arr SimpleAggregateFunction(groupArrayArray(10000), Array(String)),
span_id_arr SimpleAggregateFunction(groupArrayArray(10000), Array(String)),
trace_flags_arr SimpleAggregateFunction(groupArrayArray(10000), Array(Int32)),
+ timestamp_min DateTime64(6) ALIAS arrayMin(timestamp_arr),
+ timestamp_max DateTime64(6) ALIAS arrayMax(timestamp_arr),
INDEX idx_metric_type_set metric_type TYPE set(10) GRANULARITY 1,
INDEX idx_time_bucket_minmax time_bucket TYPE minmax GRANULARITY 1,
- INDEX idx_trace_id_bf trace_id_arr TYPE bloom_filter(0.01) GRANULARITY 1
+ INDEX idx_trace_id_bf trace_id_arr TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX idx_timestamp_min_minmax timestamp_min TYPE minmax GRANULARITY 1,
+ INDEX idx_timestamp_max_minmax timestamp_max TYPE minmax GRANULARITY 1
) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.metrics4_samples', '{replica}-{shard}') ORDER BY (team_id, metric_name, time_bucket, series_fingerprint) PARTITION BY original_expiry_date TTL original_expiry_date SETTINGS index_granularity = 128, ttl_only_drop_parts = 1;
CREATE TABLE posthog.metrics4_series (
team_id Int32,
diff --git a/posthog/clickhouse/hcl/sql/local-single/all.sql b/posthog/clickhouse/hcl/sql/local-single/all.sql
index a00deee18cf3..96ac92b79e0a 100644
--- a/posthog/clickhouse/hcl/sql/local-single/all.sql
+++ b/posthog/clickhouse/hcl/sql/local-single/all.sql
@@ -1607,9 +1607,13 @@ CREATE TABLE posthog.metrics4_samples (
trace_id_arr SimpleAggregateFunction(groupArrayArray(10000), Array(String)),
span_id_arr SimpleAggregateFunction(groupArrayArray(10000), Array(String)),
trace_flags_arr SimpleAggregateFunction(groupArrayArray(10000), Array(Int32)),
+ timestamp_min DateTime64(6) ALIAS arrayMin(timestamp_arr),
+ timestamp_max DateTime64(6) ALIAS arrayMax(timestamp_arr),
INDEX idx_metric_type_set metric_type TYPE set(10) GRANULARITY 1,
INDEX idx_time_bucket_minmax time_bucket TYPE minmax GRANULARITY 1,
- INDEX idx_trace_id_bf trace_id_arr TYPE bloom_filter(0.01) GRANULARITY 1
+ INDEX idx_trace_id_bf trace_id_arr TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX idx_timestamp_min_minmax timestamp_min TYPE minmax GRANULARITY 1,
+ INDEX idx_timestamp_max_minmax timestamp_max TYPE minmax GRANULARITY 1
) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.metrics4_samples', '{replica}-{shard}') ORDER BY (team_id, metric_name, time_bucket, series_fingerprint) PARTITION BY original_expiry_date TTL original_expiry_date SETTINGS index_granularity = 128, ttl_only_drop_parts = 1;
CREATE TABLE posthog.metrics4_series (
team_id Int32,
diff --git a/posthog/clickhouse/hcl/sql/prod-eu/logs.sql b/posthog/clickhouse/hcl/sql/prod-eu/logs.sql
index a0514c036810..2c229af484f2 100644
--- a/posthog/clickhouse/hcl/sql/prod-eu/logs.sql
+++ b/posthog/clickhouse/hcl/sql/prod-eu/logs.sql
@@ -594,9 +594,13 @@ CREATE TABLE posthog.metrics4_samples (
trace_id_arr SimpleAggregateFunction(groupArrayArray(10000), Array(String)),
span_id_arr SimpleAggregateFunction(groupArrayArray(10000), Array(String)),
trace_flags_arr SimpleAggregateFunction(groupArrayArray(10000), Array(Int32)),
+ timestamp_min DateTime64(6) ALIAS arrayMin(timestamp_arr),
+ timestamp_max DateTime64(6) ALIAS arrayMax(timestamp_arr),
INDEX idx_metric_type_set metric_type TYPE set(10) GRANULARITY 1,
INDEX idx_time_bucket_minmax time_bucket TYPE minmax GRANULARITY 1,
- INDEX idx_trace_id_bf trace_id_arr TYPE bloom_filter(0.01) GRANULARITY 1
+ INDEX idx_trace_id_bf trace_id_arr TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX idx_timestamp_min_minmax timestamp_min TYPE minmax GRANULARITY 1,
+ INDEX idx_timestamp_max_minmax timestamp_max TYPE minmax GRANULARITY 1
) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.metrics4_samples', '{replica}-{shard}') ORDER BY (team_id, metric_name, time_bucket, series_fingerprint) PARTITION BY original_expiry_date TTL original_expiry_date SETTINGS index_granularity = 128, ttl_only_drop_parts = 1;
CREATE TABLE posthog.metrics4_series (
team_id Int32,
diff --git a/posthog/clickhouse/hcl/sql/prod-us/logs.sql b/posthog/clickhouse/hcl/sql/prod-us/logs.sql
index 8d44bd2d5f42..7a315ec6f628 100644
--- a/posthog/clickhouse/hcl/sql/prod-us/logs.sql
+++ b/posthog/clickhouse/hcl/sql/prod-us/logs.sql
@@ -594,9 +594,13 @@ CREATE TABLE posthog.metrics4_samples (
trace_id_arr SimpleAggregateFunction(groupArrayArray(10000), Array(String)),
span_id_arr SimpleAggregateFunction(groupArrayArray(10000), Array(String)),
trace_flags_arr SimpleAggregateFunction(groupArrayArray(10000), Array(Int32)),
+ timestamp_min DateTime64(6) ALIAS arrayMin(timestamp_arr),
+ timestamp_max DateTime64(6) ALIAS arrayMax(timestamp_arr),
INDEX idx_metric_type_set metric_type TYPE set(10) GRANULARITY 1,
INDEX idx_time_bucket_minmax time_bucket TYPE minmax GRANULARITY 1,
- INDEX idx_trace_id_bf trace_id_arr TYPE bloom_filter(0.01) GRANULARITY 1
+ INDEX idx_trace_id_bf trace_id_arr TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX idx_timestamp_min_minmax timestamp_min TYPE minmax GRANULARITY 1,
+ INDEX idx_timestamp_max_minmax timestamp_max TYPE minmax GRANULARITY 1
) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.metrics4_samples', '{replica}-{shard}') ORDER BY (team_id, metric_name, time_bucket, series_fingerprint) PARTITION BY original_expiry_date TTL original_expiry_date SETTINGS index_granularity = 128, ttl_only_drop_parts = 1;
CREATE TABLE posthog.metrics4_series (
team_id Int32,
diff --git a/posthog/clickhouse/metrics/metrics4.py b/posthog/clickhouse/metrics/metrics4.py
index 6235ef28bcfa..a4ac8b1ea14f 100644
--- a/posthog/clickhouse/metrics/metrics4.py
+++ b/posthog/clickhouse/metrics/metrics4.py
@@ -215,9 +215,13 @@ CREATE TABLE IF NOT EXISTS {_db()}.{METRICS4_SAMPLES_TABLE_NAME}
`histogram_bounds` SimpleAggregateFunction(anyLast, Array(Float64)),
`_topic` SimpleAggregateFunction(any, LowCardinality(String)),
{arrays},
+ `timestamp_min` DateTime64(6) ALIAS arrayMin(timestamp_arr),
+ `timestamp_max` DateTime64(6) ALIAS arrayMax(timestamp_arr),
INDEX idx_metric_type_set metric_type TYPE set(10) GRANULARITY 1,
INDEX idx_time_bucket_minmax time_bucket TYPE minmax GRANULARITY 1,
- INDEX idx_trace_id_bf trace_id_arr TYPE bloom_filter(0.01) GRANULARITY 1
+ INDEX idx_trace_id_bf trace_id_arr TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX idx_timestamp_min_minmax timestamp_min TYPE minmax GRANULARITY 1,
+ INDEX idx_timestamp_max_minmax timestamp_max TYPE minmax GRANULARITY 1
)
ENGINE = {AggregatingMergeTree(METRICS4_SAMPLES_TABLE_NAME, replication_scheme=ReplicationScheme.REPLICATED)}
PARTITION BY original_expiry_date
diff --git a/posthog/clickhouse/migrations/0331_metrics4_samples_timestamp_minmax.py b/posthog/clickhouse/migrations/0331_metrics4_samples_timestamp_minmax.py
new file mode 100644
index 000000000000..0d083f2e6f32
--- /dev/null
+++ b/posthog/clickhouse/migrations/0331_metrics4_samples_timestamp_minmax.py
@@ -0,0 +1,23 @@
+"""AUTO-GENERATED from the declarative HCL by posthog/clickhouse/hcl/codegen/gen_migration.py.
+Placement (node_roles) is derived from the node composition manifest; review before committing.
+"""
+
+from django.conf import settings
+
+from posthog.clickhouse.client.connection import NodeRole
+from posthog.clickhouse.client.migration_tools import run_sql_with_exceptions
+
+DB = settings.CLICKHOUSE_LOGS_CLUSTER_DATABASE
+
+operations = [
+ run_sql_with_exceptions(
+ f"ALTER TABLE {DB}.metrics4_samples "
+ "ADD COLUMN IF NOT EXISTS timestamp_min DateTime64(6) ALIAS arrayMin(timestamp_arr), "
+ "ADD COLUMN IF NOT EXISTS timestamp_max DateTime64(6) ALIAS arrayMax(timestamp_arr), "
+ "ADD INDEX IF NOT EXISTS idx_timestamp_min_minmax timestamp_min TYPE minmax GRANULARITY 1, "
+ "ADD INDEX IF NOT EXISTS idx_timestamp_max_minmax timestamp_max TYPE minmax GRANULARITY 1",
+ node_roles=[NodeRole.LOGS],
+ sharded=False,
+ is_alter_on_replicated_table=True,
+ ),
+]
diff --git a/posthog/clickhouse/migrations/max_migration.txt b/posthog/clickhouse/migrations/max_migration.txt
index b56505cc2a10..f6e76c5ef26c 100644
--- a/posthog/clickhouse/migrations/max_migration.txt
+++ b/posthog/clickhouse/migrations/max_migration.txt
@@ -1 +1 @@
-0330_trace_spans_retention_days
+0331_metrics4_samples_timestamp_minmax
diff --git a/posthog/clickhouse/test/__snapshots__/test_schema.ambr b/posthog/clickhouse/test/__snapshots__/test_schema.ambr
index 3aaad87d8589..4c95547f91c5 100644
--- a/posthog/clickhouse/test/__snapshots__/test_schema.ambr
+++ b/posthog/clickhouse/test/__snapshots__/test_schema.ambr
@@ -5250,9 +5250,13 @@
`trace_id_arr` SimpleAggregateFunction(groupArrayArray(10000), Array(String)),
`span_id_arr` SimpleAggregateFunction(groupArrayArray(10000), Array(String)),
`trace_flags_arr` SimpleAggregateFunction(groupArrayArray(10000), Array(Int32)),
+ `timestamp_min` DateTime64(6) ALIAS arrayMin(timestamp_arr),
+ `timestamp_max` DateTime64(6) ALIAS arrayMax(timestamp_arr),
INDEX idx_metric_type_set metric_type TYPE set(10) GRANULARITY 1,
INDEX idx_time_bucket_minmax time_bucket TYPE minmax GRANULARITY 1,
- INDEX idx_trace_id_bf trace_id_arr TYPE bloom_filter(0.01) GRANULARITY 1
+ INDEX idx_trace_id_bf trace_id_arr TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX idx_timestamp_min_minmax timestamp_min TYPE minmax GRANULARITY 1,
+ INDEX idx_timestamp_max_minmax timestamp_max TYPE minmax GRANULARITY 1
)
ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/77f1df52-4b43-11e9-910f-b8ca3a9b9f3e_noshard/posthog.metrics4_samples', '{replica}-{shard}')
PARTITION BY original_expiry_date
@@ -12499,9 +12503,13 @@
`trace_id_arr` SimpleAggregateFunction(groupArrayArray(10000), Array(String)),
`span_id_arr` SimpleAggregateFunction(groupArrayArray(10000), Array(String)),
`trace_flags_arr` SimpleAggregateFunction(groupArrayArray(10000), Array(Int32)),
+ `timestamp_min` DateTime64(6) ALIAS arrayMin(timestamp_arr),
+ `timestamp_max` DateTime64(6) ALIAS arrayMax(timestamp_arr),
INDEX idx_metric_type_set metric_type TYPE set(10) GRANULARITY 1,
INDEX idx_time_bucket_minmax time_bucket TYPE minmax GRANULARITY 1,
- INDEX idx_trace_id_bf trace_id_arr TYPE bloom_filter(0.01) GRANULARITY 1
+ INDEX idx_trace_id_bf trace_id_arr TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX idx_timestamp_min_minmax timestamp_min TYPE minmax GRANULARITY 1,
+ INDEX idx_timestamp_max_minmax timestamp_max TYPE minmax GRANULARITY 1
)
ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/77f1df52-4b43-11e9-910f-b8ca3a9b9f3e_noshard/posthog.metrics4_samples', '{replica}-{shard}')
PARTITION BY original_expiry_date