mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-01 07:03:02 +00:00
perf(schema): index LiteLLM_SpendLogs by session for the session view
Add (session_id, api_key, startTime DESC, request_id) so checking whether a spend log row is the newest row of its session is one index probe. The migration builds it CONCURRENTLY so spend log inserts keep flowing during a rolling deploy.
This commit is contained in:
parent
3b715525d3
commit
04d4a19c9d
4 changed files with 5 additions and 0 deletions
|
|
@ -0,0 +1,2 @@
|
|||
-- CreateIndex (CONCURRENTLY): keep this a single statement so Prisma Migrate applies it outside a transaction
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS "LiteLLM_SpendLogs_session_id_api_key_startTime_request_id_idx" ON "LiteLLM_SpendLogs"("session_id", "api_key", "startTime" DESC, "request_id");
|
||||
|
|
@ -684,6 +684,7 @@ model LiteLLM_SpendLogs {
|
|||
@@index([session_id])
|
||||
@@index([litellm_call_id])
|
||||
@@index([api_key, startTime])
|
||||
@@index([session_id, api_key, startTime(sort: Desc), request_id])
|
||||
}
|
||||
|
||||
model LiteLLM_BudgetWindowSpend {
|
||||
|
|
|
|||
|
|
@ -684,6 +684,7 @@ model LiteLLM_SpendLogs {
|
|||
@@index([session_id])
|
||||
@@index([litellm_call_id])
|
||||
@@index([api_key, startTime])
|
||||
@@index([session_id, api_key, startTime(sort: Desc), request_id])
|
||||
}
|
||||
|
||||
model LiteLLM_BudgetWindowSpend {
|
||||
|
|
|
|||
|
|
@ -684,6 +684,7 @@ model LiteLLM_SpendLogs {
|
|||
@@index([session_id])
|
||||
@@index([litellm_call_id])
|
||||
@@index([api_key, startTime])
|
||||
@@index([session_id, api_key, startTime(sort: Desc), request_id])
|
||||
}
|
||||
|
||||
model LiteLLM_BudgetWindowSpend {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue