diff --git a/gcloud/contrib/template_market/models.py b/gcloud/contrib/template_market/models.py index 510c3c3e0..016c64727 100644 --- a/gcloud/contrib/template_market/models.py +++ b/gcloud/contrib/template_market/models.py @@ -16,6 +16,8 @@ from gcloud import err_code +TEMPLATE_SHARED_RECORD_BATCH_OPERATION_COUNT = 50 + class TemplateSharedManager(models.Manager): def update_shared_record( @@ -66,9 +68,12 @@ def update_shared_record( new_records.append(new_record) if new_records: - TemplateSharedRecord.objects.bulk_create(new_records) + TemplateSharedRecord.objects.bulk_create(batch_size=TEMPLATE_SHARED_RECORD_BATCH_OPERATION_COUNT) + if records_to_update: - TemplateSharedRecord.objects.bulk_update(records_to_update, ["extra_info"]) + TemplateSharedRecord.objects.bulk_update( + records_to_update, ["extra_info"], batch_size=TEMPLATE_SHARED_RECORD_BATCH_OPERATION_COUNT + ) return {"result": True, "message": "update shared record successfully", "code": err_code.SUCCESS.code}