Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add WHERE filter to the SQL update

Ania Warzechaf8f0daff90cd
diff --git a/saleor/attribute/migrations/tasks/saleor3_16.py b/saleor/attribute/migrations/tasks/saleor3_16.py
index a7c27d81df..9abcd052bf 100644
--- a/saleor/attribute/migrations/tasks/saleor3_16.py
+++ b/saleor/attribute/migrations/tasks/saleor3_16.py
@@ -5,7 +5,7 @@ from django.db import transaction, connection
# batch size to make sure that task is completed in 1 second
# and we don't use too much memory
-BATCH_SIZE = 1000
+PRODUCT_BATCH_SIZE = 1000
PAGE_BATCH_SIZE = 5000
@@ -27,12 +27,13 @@ def update_product_assignment():
)
WHERE id IN (
SELECT ID FROM attribute_assignedproductattributevalue
+ WHERE product_id IS NULL
ORDER BY ID DESC
FOR UPDATE
LIMIT %s
);
""", # noqa
- [BATCH_SIZE],
+ [PRODUCT_BATCH_SIZE],
)