django>=1.8 required, speed up bulk_update, new feature #54
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi @aykut,
First of all, I know that it's a huge PR with a lot of changes, so there's no rush, and feel free to deny any change. Any comment will be appreciated.
Commit 79549fe "Drop support for django<1.8":
django<1.8
, and adddjango>=1.8
as installation requirement.python3.4
topython3.5
.Commit 301eaa5 "Rename module from bulk_update to django_bulk_update":
Commit 9cf8c70 "Remove deprecated code.":
Commit 0818448 "Refactor 'bulk_update'."
bulk_update
function in order to speed it up.I performed a speed test with a model called Lead which has 50 fields:
First I commented out the line that executes the query, so we are just measuring how much time it takes to build the query, not the query executing time.
Results with the current function:
and with the refactored function:
Conclusion: the new version is faster and it has a linear growth with respect to the number of objects to update.
Commit 1b67304 "Make bulk_update work with django expressions like the 'F expressions'.":
F
,Func
,Concat
to update object values.For example: