Skip to content

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

perf(blob-export): replace observations FINAL with LIMIT 1 BY (#13935)

Niklas Semmler09d33b269d54
diff --git a/packages/shared/src/server/repositories/observations.ts b/packages/shared/src/server/repositories/observations.ts
index c967787dcd..199211ff6d 100644
--- a/packages/shared/src/server/repositories/observations.ts
+++ b/packages/shared/src/server/repositories/observations.ts
@@ -1843,10 +1843,12 @@ export const getObservationsForBlobStorageExport = function (
tool_call_names,
tool_definitions,
usage_pricing_tier_name
- FROM observations FINAL
+ FROM observations
WHERE project_id = {projectId: String}
AND start_time >= {minTimestamp: DateTime64(3)}
AND start_time <= {maxTimestamp: DateTime64(3)}
+ ORDER BY event_ts DESC
+ LIMIT 1 BY id, project_id, type
`;
const records = queryClickhouseStream<Record<string, unknown>>({