Skip to content

perf: reduce trending job score writes#967

Merged
raymondjacobson merged 1 commit into
mainfrom
codex/reduce-trending-job-db-load
Jun 22, 2026
Merged

perf: reduce trending job score writes#967
raymondjacobson merged 1 commit into
mainfrom
codex/reduce-trending-job-db-load

Conversation

@raymondjacobson

@raymondjacobson raymondjacobson commented Jun 22, 2026

Copy link
Copy Markdown
Member

Summary

  • Persist only positive track trending scores while keeping the existing score expressions intact, reducing the zero-score tail rewritten by TrendingJob.
  • Drop superseded ascending-tiebreak track trending indexes now covered by desc-tiebreak indexes.
  • Align challenge/tastemaker trending reads with the desc-tiebreak index order and add tests for positive-row persistence plus zero-score pruning.

Production evidence

  • track_trending_scores is about 12.2M rows / 17GB total in prod, with about 16GB of indexes.
  • Read-only prod counts showed only about 2.31M positive track score rows; week/month ranges are overwhelmingly zero-score rows.
  • score is NOT NULL in prod, so removing NULLS LAST from challenge reads should preserve ordering while letting Postgres use the existing desc-tiebreak indexes.

Compatibility note

  • This intentionally stops returning arbitrary zero-score filler rows from track_trending_scores. Shallow trending reads should be unaffected, but very deep pagination or sparse genre queries may return fewer rows after all positive scores are exhausted.

Test plan

  • go test ./jobs -run TestTrendingJob -count=1
  • go test ./jobs/challenges -run "TestTrending|TestTastemaker" -count=1
  • go test ./api -run "Trending|RecommendedTracks|GenreTop" -count=1
  • git diff --check

@raymondjacobson raymondjacobson merged commit 2a76325 into main Jun 22, 2026
5 checks passed
@raymondjacobson raymondjacobson deleted the codex/reduce-trending-job-db-load branch June 22, 2026 22:33
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