-
Notifications
You must be signed in to change notification settings - Fork 487
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
Re-add support for bulk_create
#924
Re-add support for bulk_create
#924
Comments
Hello friends, this would be really useful to me also. I've got some objects that I create through bulk_insert or update with bulk_update and I am forced to save them one-by-one to have proper revisions. |
I'm a bit short on time at the moment, but I'd be happy to take a PR that implemented this. |
So this, specifically, is another problem than what's described in this issue! A workaround for your problem is explained here: Essentially, if you use bulk_create or bulk_update to update a lot of models in one query, also iterate over the objects and call |
Between 1.8.0 and 1.8.6 (#380), reversion used
bulk_create
when creating versions, which presumably dramatically improved performance when creating a revision with many changed model instances[1]. It sounds like the motivation for removing this was inability to get back object primary keys frombulk_create
, but that has since been fixed on some popular databases -- Django 1.10 (released about a year and a half after #380) added some support (only PostgreSQL at the time). SQLite was added in Django 4.0, and MariaDB was added sometime in the middle. It looks like there's a convenient feature test for this (connection.features.can_return_rows_from_bulk_insert
), so it would be nice if django-reversion could usebulk_create
when feasible.(I found #380 while trying to figure out why tons of queries were being used despite the changelog claiming reversion uses bulk_create, so if you don't re-add
bulk_create
support it might be nice to note the change somewhere?)[1] I haven't benchmarked this specifically, but a script that creates several thousand objects went from 30 minute runtime to ~3 minutes by doing far more query batching, so I suspect this is significant.
The text was updated successfully, but these errors were encountered: