Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix: add idx on LOWER(user_email) for faster duplicate email checks log(n) B tree approach (#18828)

Harshit Jain1d296a990c92
diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20260108_add_user_email_lower_idx/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260108_add_user_email_lower_idx/migration.sql
new file mode 100644
index 00000000000..add80b39e7f
--- /dev/null
+++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260108_add_user_email_lower_idx/migration.sql
@@ -0,0 +1,9 @@
+-- CreateIndex
+-- Fixes performance issue in _check_duplicate_user_email function
+-- by enabling fast case-insensitive email lookups.
+--
+-- Without this index, queries with mode: "insensitive" cause full table scans.
+-- With this index, PostgreSQL can use an Index Scan for O(log n) performance.
+--
+-- Related: GitHub Issue #18411
+CREATE INDEX "LiteLLM_UserTable_user_email_lower_idx" ON "LiteLLM_UserTable"(LOWER("user_email"));