CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ppl_candidate_lookup_matchup
ON public."PlayerPropLine" (
  lower(league),
  "gameStart",
  lower(COALESCE("propType", '')),
  upper(COALESCE("homeTeam", '')),
  upper(COALESCE("awayTeam", '')),
  "updatedAt" DESC
)
WHERE
  "oddsAmerican" IS NOT NULL
  AND "lineValue" IS NOT NULL
  AND (
    COALESCE("marketScope", '') IN ('full_game', 'game')
    OR lower(COALESCE(raw->>'period', raw #>> '{sportsgameodds,periodID}', '')) = 'game'
    OR lower(COALESCE(market, '')) LIKE 'game_%'
  );
