Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

perf: reduce scan size for event prop by converting OR to GREATEST (#12221)

Steffen Schmitz347b21e8e3bf
diff --git a/worker/src/features/eventPropagation/handleEventPropagationJob.ts b/worker/src/features/eventPropagation/handleEventPropagationJob.ts
index c93ebf6f2c..fb8045ae42 100644
--- a/worker/src/features/eventPropagation/handleEventPropagationJob.ts
+++ b/worker/src/features/eventPropagation/handleEventPropagationJob.ts
@@ -168,8 +168,7 @@ export const handleEventPropagationJob = async (
-- For some reason clickhouse detects any "date >= '1969-12-31'" as false.
-- Therefore, we add a fallback condition that limits actively to last 7 days.
-- This means that 7 days becomes the maximum trace data propagation interval.
- t.timestamp >= (select min(min_start_time) - interval 1 day from batch_stats) OR
- t.timestamp >= now() - interval 7 day
+ t.timestamp >= greatest((select min(min_start_time) - interval 1 day from batch_stats), now() - interval 7 day)
)
and t.timestamp <= (select max(max_start_time) + interval 1 day from batch_stats)
order by t.event_ts desc