-
Notifications
You must be signed in to change notification settings - Fork 77
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
Speed up long-running migrations #2552
Speed up long-running migrations #2552
Conversation
I applied your patch and it seems I got through
|
I also applied the following change: diff --git a/database/migrations/2024_08_24_160326_label2test_relationship_refactor.php b/database/migrations/2024_08_24_160326_label2test_relationship_refactor.php
index 67994ad43..64b7745db 100644
--- a/database/migrations/2024_08_24_160326_label2test_relationship_refactor.php
+++ b/database/migrations/2024_08_24_160326_label2test_relationship_refactor.php
@@ -22,7 +22,7 @@ return new class extends Migration {
// Execute at most 10k batches of buildwise updates
if (config('database.default') === 'pgsql') {
- for ($i = 0; $i < ceil($count / 10000); $i++) {
+ for ($i = 1; $i < ceil($count / 10000); $i++) {
DB::update('
UPDATE label2test
SET testid = build2test.id Then the migrations completed. |
For me the label2test table was empty, so we did not run into this problem @bilke : I am not sure about your fix, but if the count is less than 10000, then the loop will not execute at all, probably it needs to be changed to Feedback from Kitware would be nice here. But for me it looks like the current implementation will cause the division by zero problem and should be changed |
It looks like there are two issues here:
|
I am not sure if batching would really help here. For us 1.5 million entries of Here are just a few references suggesting to replace
If you want to keep the current implementation for MySQL, I could adjust the code thus that |
3872843
to
c601505
Compare
@stefankaufmann Thanks for this contribution! After playing around with this locally a bit, I didn't see any negative performance impacts of this change when using MySQL, and it clearly seems to help Postgres. I also created #2555 which fixes the other divide-by-zero error reported above. Both of these changes will be included in a patch release: CDash 3.6.1. |
@williamjallen Thanks a lot. I really appreciate how quick my pull requests have been processed |
As reported in #2552 (comment), #2496 introduced a divide-by-zero error in the migration `2024_08_24_160326_label2test_relationship_refactor`. This PR fixes the issue.
Boost performance for migrations scripts