fix: add missing indexes on FK columns in stratplay and stratgame (#74) #95
1288
app/db_engine.py
1288
app/db_engine.py
File diff suppressed because it is too large
Load Diff
24
migrations/2026-03-27_add_stratplay_stratgame_indexes.sql
Normal file
24
migrations/2026-03-27_add_stratplay_stratgame_indexes.sql
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
-- Migration: Add missing indexes on foreign key columns in stratplay and stratgame
|
||||||
|
-- Created: 2026-03-27
|
||||||
|
--
|
||||||
|
-- PostgreSQL does not auto-index foreign key columns. These tables are the
|
||||||
|
-- highest-volume tables in the schema and are filtered/joined on these columns
|
||||||
|
-- in batting, pitching, and running stats aggregation and standings recalculation.
|
||||||
|
|
||||||
|
-- stratplay: FK join column
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_stratplay_game_id ON stratplay(game_id);
|
||||||
|
|
||||||
|
-- stratplay: filtered in batting stats aggregation
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_stratplay_batter_id ON stratplay(batter_id);
|
||||||
|
|
||||||
|
-- stratplay: filtered in pitching stats aggregation
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_stratplay_pitcher_id ON stratplay(pitcher_id);
|
||||||
|
|
||||||
|
-- stratplay: filtered in running stats
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_stratplay_runner_id ON stratplay(runner_id);
|
||||||
|
|
||||||
|
-- stratgame: heavily filtered by season
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_stratgame_season ON stratgame(season);
|
||||||
|
|
||||||
|
-- stratgame: standings recalculation query ordering
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_stratgame_season_week_game_num ON stratgame(season, week, game_num);
|
||||||
Loading…
Reference in New Issue
Block a user