Skip to content

database/versions: Add generated version_no_prerelease column #3992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

Turbo87
Copy link
Member

@Turbo87 Turbo87 commented Oct 7, 2021

This is an attempt to speed up the reverse dependencies query, as hinted at in #3886 (comment).

Instead of running to_semver_no_prerelease(num) in every query, we use a generated column to speed up the query.

In my local tests with the imported database dump the query times were previously around 1700ms for the rand crate, and after this change they consistently dropped down to around 900ms.

@Turbo87 Turbo87 added C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear A-backend ⚙️ labels Oct 7, 2021
@Turbo87
Copy link
Member Author

Turbo87 commented Oct 8, 2021

rebased on top of #3993 to fix the versions table trigger issue that was causing the tests to fail.

@Turbo87 Turbo87 marked this pull request as draft October 14, 2021 07:53
bors added a commit that referenced this pull request Oct 14, 2021
database: Simplify `trigger_versions_set_updated_at` trigger on the `versions` table

The only mutable columns in this table are `yanked` and `downloads`, but the trigger should specifically not be used when the `downloads` column changes. That means we're only left with the `yanked` column and can be more specific in the trigger condition.

This unblocks #3992, but also generally simplifies the table trigger.
@Turbo87
Copy link
Member Author

Turbo87 commented Oct 17, 2021

@Turbo87 Turbo87 closed this Oct 17, 2021
@Turbo87 Turbo87 deleted the generated-column branch October 17, 2022 17:35
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.

1 participant