-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Eliminate usage of bulk_create()
and bulk_update()
methods outside of tests and migrations
#10694
Comments
bulk_create()
and bulk_create()
methods outside of tests and migrationsbulk_create()
and bulk_update()
methods outside of tests and migrations
bulk_create used in:
bulk_update used in:
|
Rather than eliminating their usage, which would incur significant performance penalties when performing certain operations, we could instead manually trigger the |
…s in bulk (#10900) * Emit post_save signal when creating/updating device components in bulk * Fix post_save for bulk_update()
The hybrid approach I mentioned above seems to save a substantial amount of time compared to completely removing the bulk calls (despite still being far slower than the current implementation, which does not support change logging). I've merged PR #10900 using this approach and will test during the v3.4 beta release. Should any serious issues with this approach surface, we'll revert to the approach in PR #10780. |
Proposed Changes
While we've generally avoided the use of
bulk_create()
andbulk_update()
for the bulk creation and manipulation of objects due to the caveats associated with their use (namely not triggering thepost_save
signal), they are still used in a few areas within NetBox. The goal of this issue is to eliminate any usage of these methods, excluding within tests and migrations where specifically needed to ensure optimal performance.Justification
As calling
bulk_create()
orbulk_update()
does not generate apost_save
signal for each of the objects affected, this escapes change logging and (in NetBox v3.4) search indexing. Although callingsave()
on each instance individual will impose a performance penalty, it ensures that each instance is subject to the appropriate background workflows. (This was initially called out here by @kkthxbye-code.)The text was updated successfully, but these errors were encountered: