Skip to content
TypeScript

perf(server): pin the index for the unscoped agent event high-water (#29623)

Julius Marminge065a43355c76
diff --git a/apps/server/src/persistence/OrchestrationEventStore.ts b/apps/server/src/persistence/OrchestrationEventStore.ts
index 51c3861a9fc..dbea09d6669 100644
--- a/apps/server/src/persistence/OrchestrationEventStore.ts
+++ b/apps/server/src/persistence/OrchestrationEventStore.ts
@@ -645,7 +645,8 @@ const makeEventStore = Effect.gen(function* () {
FROM orchestration_events
${
threadId === undefined
- ? sql``
+ ? // The planner can otherwise pick the covering stream index and scan every agent event.
+ sql`INDEXED BY idx_orchestration_events_application_sequence`
: sql`INDEXED BY idx_orchestration_events_agent_stream_sequence`
}
WHERE application_event_version = 2