Faster db updates for Django using UPDATE FROM VALUES sql variants.
Low maintenance activity. Last release 16 months ago, commits in 0 of the last 26 weeks. Weaker on commit activity and recent releases.
pip install django-fast-updatedjango-fast-update
Faster db updates using UPDATE FROM VALUES sql variants.
Installation & Usage
Run pip install django-fast-update and place fast_update in INSTALLED_APPS.
With attaching FastUpdateManager as a manager to your model, fast_update
can be used instead of bulk_update, e.g.:
from django.db import models
from fast_update.query import FastUpdateManager
class MyModel(models.Model):
objects = FastUpdateManager()
field_a = ...
field_b = ...
field_c = ...
# to update multiple instances at once:
MyModel.objects.fast_update(bunch_of_instances, ['field_a', 'field_b', 'field_c'])
Alternatively fast.fast_update can be used directly with a queryset as first argument
(Warning - this skips most sanity checks with up to 30% speed gain,
so make sure not to feed something totally off).
Compatibility
fast_update is known to work with these database versions:
- SQLite 3.15+
- PostgreSQL
- MariaDB 10.2+
- MySQL 5.7+
For unsupported database backends or outdated versions fast_update will fall back to flat_update.
(It is possible to register fast update implementations for other db vendors with register_implementation.
See fast_update/fast.py for more details.)
Note that with fast_update f-expressions cannot be used anymore.
This is a design decision to not penalize update performance by some swiss-army-knife functionality.
If you have f-expressions in your update data, consider re-grouping the update steps and update those
fields with update or bulk_update instead.
Other than with bulk_update duplicates in a changeset are not allowed and will raise.
This is mainly a safety guard to not let slip through duplicates, where the final update state
would be undetermined or directly depend on the database's compatibility.