Skip to content

perf(api): drive usdc purchase tracks from trending scores#911

Open
raymondjacobson wants to merge 1 commit into
mainfrom
codex/db-audit-usdc-purchase-trending-query
Open

perf(api): drive usdc purchase tracks from trending scores#911
raymondjacobson wants to merge 1 commit into
mainfrom
codex/db-audit-usdc-purchase-trending-query

Conversation

@raymondjacobson
Copy link
Copy Markdown
Member

Summary

  • removes the materialized usdc_track_ids CTE from /v1/tracks/usdc-purchase
  • filters ordered track_trending_scores rows with an EXISTS probe against tracks
  • preserves the same eligibility predicates and ORDER BY score DESC, track_id DESC response order

Production evidence

  • the database audit found the current plan materializing eligible USDC tracks before sorting joined trending scores, with startup cost around 265k for a small page
  • the rewritten shape lets PostgreSQL start from the ordered trending-score path and probe tracks by track_id, which the audit EXPLAIN showed reducing startup work by orders of magnitude for the equivalent ordered scan/probe plan
  • this PR is code-only and independent of the separate trending-score index PR

Verification

  • go test ./api -run 'TestGetUsdcPurchase|TestGetTrendingIds' -count=1 -timeout=2m

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