-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
upgrade: improve delete dropped udf upgrade job efficiency #104512
upgrade: improve delete dropped udf upgrade job efficiency #104512
Conversation
It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR? 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
7a8e809
to
f9adf43
Compare
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @chengxiong-ruan)
pkg/upgrade/upgrades/delete_descriptors_of_dropped_functions.go
line 45 at r1 (raw file):
FROM system.descriptor WHERE id > $1
Just wondering, would it be a lot more inefficient to instead have the to_json
CTE not have a WHERE
clause and have to_delete
maybe have something like LIMIT 50
on it? (Or maybe have the LIMIT 50
on the main SELECT
itself.) And then we'd loop the query until no more rows are affected?
I still worry that looping over the descriptor IDs might be too slow and if these kind of descriptors are rare to begin with, somewhat inefficient still?
I think the optimizer would push the
I think with this approach, we still need to track the progress somehow. Otherwise it would start from the very first descriptor if there're actually some function descriptors. Maybe we could have the delete query to return the IDs as well then still filter by IDs. But I think by explicitly looping through IDs, each small batch is light and won't scan too much data.
yeah, the thing is that we have to look at every single descriptor to tell if it's a function descriptor and then to tell if it's dropped. But I won't worry about the IDs looping as long as it only look at actual existing IDs. From what I saw by testing this new. upgrade with the 4 thousand descriptor debug zip, it's much much faster now. |
f9adf43
to
c757411
Compare
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.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @chengxiong-ruan)
pkg/upgrade/upgrades/delete_descriptors_of_dropped_functions.go
line 45 at r1 (raw file):
I think with this approach, we still need to track the progress somehow. Otherwise it would start from the very first descriptor if there're actually some function descriptors.
Ah I see, I guess because it's not as straightforward as DELETE FROM ...
, you can't just use a LIMIT
directly.
pkg/upgrade/upgrades/delete_descriptors_of_dropped_functions.go
line 94 at r2 (raw file):
batchSize, ) batchMaxID := int64(tree.MustBeDInt(row[0]))
nit: this line should probably go after the err != nil
check
Release note (performance improvement): this commit makes the `delete descriptors of dropped functions` upgrade job more efficient. It used to look at every single id until the max descriptor id which was very inefficient when the max descriptor id really large, in which case the upgrade job took very long even there was no function descriptor at all. This commit changed it to actually query upper bound id of each batch.
c757411
to
b20d5ac
Compare
Previously, andyyang890 (Andy Yang) wrote…
done. good catch! |
tftr! |
Build failed: |
bors r+ |
Build succeeded: |
Informs: https://github.com/cockroachlabs/support/issues/2364
Release note (performance improvement): this commit makes the
delete descriptors of dropped functions
upgrade job more efficient. It used to look at every single id until the max descriptor id which was very inefficient when the max descriptor id really large, in which case the upgrade job took very long even there was no function descriptor at all. This commit changed it to actually query upper bound id of each batch.