From 1b1f9eb2d7dff8cf3998857bc8fbde7d6d278893 Mon Sep 17 00:00:00 2001 From: Dorian Date: Fri, 13 Mar 2026 09:41:30 +0000 Subject: [PATCH] chore: add composite (is_active, elo_rating) index for leaderboard queries All individual indexes from plan already existed. Added missing composite index that covers WHERE is_active=1 ORDER BY elo_rating DESC pattern. Co-Authored-By: Claude Opus 4.6 --- server/src/db/startup.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/server/src/db/startup.ts b/server/src/db/startup.ts index d438503..7d621e3 100644 --- a/server/src/db/startup.ts +++ b/server/src/db/startup.ts @@ -195,6 +195,7 @@ export function runMigrations() { CREATE INDEX IF NOT EXISTS idx_bots_elo ON bots(elo_rating); CREATE INDEX IF NOT EXISTS idx_bots_tier ON bots(tier); CREATE INDEX IF NOT EXISTS idx_bots_active ON bots(is_active); + CREATE INDEX IF NOT EXISTS idx_bots_active_elo ON bots(is_active, elo_rating); CREATE INDEX IF NOT EXISTS idx_rounds_fight ON rounds(fight_id); CREATE INDEX IF NOT EXISTS idx_payments_status ON payments(status); CREATE INDEX IF NOT EXISTS idx_payments_bot ON payments(bot_id);