-
Notifications
You must be signed in to change notification settings - Fork 212
fix performance regression in all releases-views #1237
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -602,6 +602,22 @@ pub fn migrate(version: Option<Version>, conn: &mut Client) -> CratesfyiResult<( | |
ALTER release_time TYPE timestamp USING release_time AT TIME ZONE 'UTC'; | ||
", | ||
), | ||
migration!( | ||
context, | ||
26, | ||
"create indexes for crates, github_repos and releases", | ||
// upgrade | ||
" | ||
CREATE INDEX crates_latest_version_idx ON crates (latest_version_id); | ||
CREATE INDEX releases_github_repo_idx ON releases (github_repo); | ||
CREATE INDEX github_repos_stars_idx ON github_repos(stars DESC); | ||
Comment on lines
+612
to
+613
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a way to measure how much disk space these take up? Anything less than ~500 MB is probably fine if it speeds up queries this much. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. full index size for the tables locally (all indexes)
if you want to check production (quickly hacked together, likely there is a nicer way, probably also by index) select
name,
pg_size_pretty(pg_relation_size(name)) as relation_size,
pg_size_pretty(pg_indexes_size(name)) as indexes_size
FROM
(
select 'crates' as name UNION ALL
select 'releases' as name UNION ALL
select 'github_repos' as name
) as ii
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah that seems fine. |
||
", | ||
" | ||
DROP INDEX crates_latest_version_idx; | ||
DROP INDEX releases_github_repo_idx; | ||
DROP INDEX github_repos_stars_idx; | ||
", | ||
), | ||
]; | ||
|
||
for migration in migrations { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
latest_version_id
is denormalized data, I think. We should be able to recalculate it fromrelease_time
, although I guess if we ever fix #708 that would have to change.No need to change it here, mostly just musing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked,
latest_version_id
is set indb::add_package::add_package_into_database
.So we should be fine.
If we ever change that for #708 (which seems to be not only a technical change, but a change in the meaning of the lists), we will either drop the field (which let's the tests here fail), or fill the field with the (then) correct version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In then, we previously used the field in the
WHERE
part, so that doesn't change :)