Skip to content

perf(db): index playlist trending order#906

Open
raymondjacobson wants to merge 1 commit into
mainfrom
codex/db-audit-playlist-trending-index
Open

perf(db): index playlist trending order#906
raymondjacobson wants to merge 1 commit into
mainfrom
codex/db-audit-playlist-trending-index

Conversation

@raymondjacobson
Copy link
Copy Markdown
Member

Summary

  • adds a concurrent index on playlist_trending_scores(type, version, time_range, score DESC, playlist_id DESC)
  • covers /v1/playlists/trending and For You playlist candidate sources without changing API behavior

Production evidence

  • the database audit found playlist trending plans doing a parallel scan and sort for the hot ORDER BY score DESC, playlist_id DESC LIMIT ... pattern
  • the production-only idx_playlist_trending_scores_filtered puts playlist_id before score, which cannot satisfy the requested ordering
  • callers filter by type, version, and time_range, then page by score/tie-breaker; this index follows that shape directly

Verification

  • migration review only; SQL is CREATE INDEX CONCURRENTLY IF NOT EXISTS plus an index comment
  • no application code changed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant