Skip to content

Conversation

@Turbo87
Copy link
Member

@Turbo87 Turbo87 commented Nov 4, 2025

Replace Rust-side sorting with database-level ORDER BY clause to improve performance. Instead of loading all versions and using max() on the Rust side, the query now:

  1. Orders by yanked (non-yanked first)
  2. Orders by prerelease status using jsonb_typeof(semver_ord[3])
  3. Orders by semver_ord descending
  4. Orders by id descending as tiebreaker

This matches the existing Version::ord_tuple() logic while being more efficient by retrieving only the default version from the database.

Replace Rust-side sorting with database-level ORDER BY clause to improve
performance. Instead of loading all versions and using `max()` on the
Rust side, the query now:

1. Orders by `yanked` (non-yanked first)
2. Orders by prerelease status using `jsonb_typeof(semver_ord[3])`
3. Orders by `semver_ord` descending
4. Orders by `id` descending as tiebreaker

This matches the existing `Version::ord_tuple()` logic while being more
efficient by retrieving only the default version from the database.
@Turbo87 Turbo87 requested a review from eth3lbert November 4, 2025 09:18
@Turbo87 Turbo87 added C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear A-backend ⚙️ labels Nov 4, 2025
Copy link
Contributor

@eth3lbert eth3lbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, thanks!

@Turbo87 Turbo87 merged commit 9387835 into rust-lang:main Nov 4, 2025
10 checks passed
@Turbo87 Turbo87 deleted the optimize-default-version-query branch November 4, 2025 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-backend ⚙️ C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants