From 4479944d35e0676154daf5b31d38b6c651a4ade1 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 6 May 2026 15:31:50 -0700 Subject: [PATCH] fix(cloud-agents): index worker_jwt_hash to avoid full scans (Greptile P2) LIT-2890 / B2's long-poll heartbeat calls find_worker_by_jwt on every request, which filters by worker_jwt_hash. Without an index that's a full table scan per heartbeat once the worker pool grows past a handful of rows. Adding the index now so it lands with the table create rather than as a follow-up migration during B2 ramp-up. --- .../migration.sql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20260506220000_add_cloud_agent_settings_tables/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260506220000_add_cloud_agent_settings_tables/migration.sql index fc79fda16b5..390ed8ea4c4 100644 --- a/litellm-proxy-extras/litellm_proxy_extras/migrations/20260506220000_add_cloud_agent_settings_tables/migration.sql +++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260506220000_add_cloud_agent_settings_tables/migration.sql @@ -67,6 +67,11 @@ CREATE TABLE IF NOT EXISTS "LiteLLM_AgentWorker" ( ); CREATE INDEX IF NOT EXISTS "LiteLLM_AgentWorker_team_id_status_idx" ON "LiteLLM_AgentWorker" ("team_id", "status"); +-- Lookup by JWT digest is on the hot path — every worker long-poll +-- heartbeat (LIT-2890 / B2) calls `find_worker_by_jwt`, which filters +-- by this column. Without an index that's a full scan per heartbeat. +CREATE INDEX IF NOT EXISTS "LiteLLM_AgentWorker_worker_jwt_hash_idx" + ON "LiteLLM_AgentWorker" ("worker_jwt_hash"); CREATE TABLE IF NOT EXISTS "LiteLLM_AgentWorkerPairingToken" ( "token_hash" TEXT PRIMARY KEY,