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.
This commit is contained in:
Ishaan Jaff 2026-05-06 15:31:50 -07:00
parent efcdbee010
commit 4479944d35
No known key found for this signature in database

View file

@ -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,