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 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-13 09:41:30 +00:00
co-authored by Claude Opus 4.6
parent d3bb00c5c8
commit 1b1f9eb2d7
+1
View File
@@ -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_elo ON bots(elo_rating);
CREATE INDEX IF NOT EXISTS idx_bots_tier ON bots(tier); 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 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_rounds_fight ON rounds(fight_id);
CREATE INDEX IF NOT EXISTS idx_payments_status ON payments(status); CREATE INDEX IF NOT EXISTS idx_payments_status ON payments(status);
CREATE INDEX IF NOT EXISTS idx_payments_bot ON payments(bot_id); CREATE INDEX IF NOT EXISTS idx_payments_bot ON payments(bot_id);