Skip to content

perf(api): align trending ids query with index order#903

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

perf(api): align trending ids query with index order#903
raymondjacobson wants to merge 1 commit into
mainfrom
codex/db-audit-trending-ids-index-order

Conversation

@raymondjacobson
Copy link
Copy Markdown
Member

Summary

  • remove a LEFT JOIN from getTrendingIds that did not filter rows
  • add a concurrent index matching the existing ORDER BY score DESC, track_id DESC tie-breaker
  • keep API ordering behavior unchanged for score ties

Production evidence

  • EXPLAIN for the current query planned a nested-loop left join plus incremental sort with startup cost ~309
  • removing the inert join and matching index order lets PostgreSQL satisfy the hot lookup from the ordered btree path
  • targeted tests caught that track_id DESC is expected for ties, so this PR preserves that contract

Verification

  • go test ./api -run 'TestGetTrendingIds|TestGetTrendingUnderground' -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