-
-
Notifications
You must be signed in to change notification settings - Fork 355
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
Bulk Create without returning objects #1614
Comments
Hi! I think ideally would be to support id population for backends that allow it to do in same query - as with As right now returning objects doesn't bring any benefits, as we return what we got in - I don't see much value in this return and we can change it I think most explicit way to do that - would be for now just removing that return object, allowing to iterate through models without loading them all in memory Next step could be adding |
Hi @abondar . I can make a PR on that, removing the returned object. |
If you could - I would gladly help you with reviewing and merging it |
The main problem here is that
bulk_create
convertsobjects
to a list before insertion which loads all the models at the same time. The only reason for this is to return the inserted objects after the query is done. However, those objects are not being updated (addingpk
for example), i.e the mothod will return what you sent. I think we can enhance this and makebulk_create
benefits from #1613 .Describe the solution you'd like
There are several approaches for this:
bulk_create
or return the number of inserted rows. This maybe a breaking change.return_objects
or something like that to control the behaviour.batch_size
is set.If none of the above seems logical, I think at least we should mention what is going behind the scenes in the docs, so the user can handle chunking on his own. And maybe use
tuple(objects)
instead oflist(objects)
.Describe alternatives you've considered
The most natural alternative is to chunk data on your side and leave
batch_size
asNone
. But this makesbatch_size
useless.The text was updated successfully, but these errors were encountered: