{"id":14972810,"url":"https://github.com/netzkolchose/django-fast-update","last_synced_at":"2025-09-08T07:36:36.206Z","repository":{"id":40649317,"uuid":"476437688","full_name":"netzkolchose/django-fast-update","owner":"netzkolchose","description":"Faster db updates using UPDATE FROM VALUES sql variants.","archived":false,"fork":false,"pushed_at":"2025-08-21T12:09:54.000Z","size":231,"stargazers_count":22,"open_issues_count":9,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-09-05T13:49:01.100Z","etag":null,"topics":["database","django","update"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/netzkolchose.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-03-31T18:50:57.000Z","updated_at":"2025-08-04T16:59:18.000Z","dependencies_parsed_at":"2024-06-21T04:19:57.508Z","dependency_job_id":"da4b9e4a-6d4b-4c77-bd8f-8b54b798eb8d","html_url":"https://github.com/netzkolchose/django-fast-update","commit_stats":{"total_commits":80,"total_committers":1,"mean_commits":80.0,"dds":0.0,"last_synced_commit":"59b0e6fa6affdcf8c66b2edee2e1bf1b926f4180"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/netzkolchose/django-fast-update","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netzkolchose%2Fdjango-fast-update","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netzkolchose%2Fdjango-fast-update/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netzkolchose%2Fdjango-fast-update/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netzkolchose%2Fdjango-fast-update/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netzkolchose","download_url":"https://codeload.github.com/netzkolchose/django-fast-update/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netzkolchose%2Fdjango-fast-update/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273819435,"owners_count":25174037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","django","update"],"created_at":"2024-09-24T13:47:34.460Z","updated_at":"2025-09-08T07:36:36.197Z","avatar_url":"https://github.com/netzkolchose.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![test](https://github.com/netzkolchose/django-fast-update/actions/workflows/django.yml/badge.svg?branch=master)](https://github.com/netzkolchose/django-fast-update/actions/workflows/django.yml)\n[![Coverage Status](https://coveralls.io/repos/github/netzkolchose/django-fast-update/badge.svg?branch=master)](https://coveralls.io/github/netzkolchose/django-fast-update?branch=master)\n\n\n## django-fast-update ##\n\nFaster db updates using `UPDATE FROM VALUES` sql variants.\n\n### Installation \u0026 Usage ###\n\nRun `pip install django-fast-update` and place `fast_update` in INSTALLED_APPS.\n\nWith attaching `FastUpdateManager` as a manager to your model, `fast_update`\ncan be used instead of `bulk_update`, e.g.:\n\n```python\nfrom django.db import models\nfrom fast_update.query import FastUpdateManager\n\nclass MyModel(models.Model):\n    objects = FastUpdateManager()\n    field_a = ...\n    field_b = ...\n    field_c = ...\n\n\n# to update multiple instances at once:\nMyModel.objects.fast_update(bunch_of_instances, ['field_a', 'field_b', 'field_c'])\n```\n\nAlternatively `fast.fast_update` can be used directly with a queryset as first argument\n(Warning - this skips most sanity checks with up to 30% speed gain,\nso make sure not to feed something totally off).\n\n\n### Compatibility ###\n\n`fast_update` is known to work with these database versions:\n\n- SQLite 3.15+\n- PostgreSQL\n- MariaDB 10.2+\n- MySQL 5.7+\n\nFor unsupported database backends or outdated versions `fast_update` will fall back to `flat_update`.\n(It is possible to register fast update implementations for other db vendors with `register_implementation`.\nSee `fast_update/fast.py` for more details.)\n\nNote that with `fast_update` f-expressions cannot be used anymore.\nThis is a design decision to not penalize update performance by some swiss-army-knife functionality.\nIf you have f-expressions in your update data, consider re-grouping the update steps and update those\nfields with `update` or `bulk_update` instead.\n\nOther than with `bulk_update` duplicates in a changeset are not allowed and will raise.\nThis is mainly a safety guard to not let slip through duplicates, where the final update state\nwould be undetermined or directly depend on the database's compatibility.\n\nBy default `flat_update` will execute another SELECT query if the queryset is prefiltered.\nSet `unfiltered=True` if you want to skip the prefiltering.\n\n\n### copy_update ###\n\nThis is a PostgreSQL only update implementation based on `COPY FROM`. This runs even faster\nthan `fast_update` for medium to big changesets (but tends to be slower than `fast_update` for \u003c100 objects).\n\n`copy_update` follows the same interface idea as `bulk_update` and `fast_update`, minus a `batch_size`\nargument (data is always transferred in one big batch). It can be used likewise from the `FastUpdateManager`.\n`copy_update` also has no support for f-expressions, also duplicates will raise.\n\n**Note** `copy_update` will probably never leave the alpha/PoC-state, as psycopg3 brings great COPY support,\nwhich does a more secure value conversion and has a very fast C-version.\n\n**Note** Django 4.2 brings psycopg3 support, which is now supported by `copy_update`.\nIt still uses the old implementation, the transition to the faster psycopg3 copy interface is still pending.\n\n\n### flat_update \u0026 merged_update ###\n\nSince version 0.3.0 the package provides 2 new update implementations. Both use direct calls of\nthe `update` method, which turns out to be much faster than `bulk_update` for local database installations\n(roughly 4x faster).\n\nWhile `flat_update` simply loops over the objects and calls `update` once with all field values applied,\n`merged_update` tries to create field value groups to lower the update calls, which will perform much better\nwith highly intersecting data.\n\nNote that `merged_update` is currently ALPHA, as the merge details and the cost prediction still need\nsome conceptual work and tests.\n\n\n### Status ###\n\nCurrently beta, still some TODOs left.\n\nThe package is tested with Django 3.2, 4.2 \u0026 5.2 on Python 3.8 to 3.13.\n\n\n### Performance ###\n\nThere is a management command in the example app testing performance of updates on the `FieldUpdate`\nmodel (`./manage.py perf`).\n\n`fast_update` is at least 8 times faster than `bulk_update`, and keeps making ground for bigger changesets.\nThis indicates different runtime complexity. `fast_update` grows almost linear for very big numbers of rows\n(tested during some perf series against `copy_update` up to 10M), while `bulk_update` grows much faster\n(looks quadratic to me, which can be lowered to linear by applying a proper `batch_size`,\nbut it stays very steep compared to `fast_update`).\n\nFor very big changesets `copy_update` is the clear winner, and even shows a substantial increase in updated rows/s\n(within my test range, as upper estimate this of course cannot grow slower than linear,\nas the data pumping will saturate to linear).\n\n\n### Changelog ###\n\n- 0.3.0 new beta release\n    - new update implementations:\n        - `flat_update`\n        - `merged_update` (ALPHA)\n    - dropped `bulk_update` as fallback\n    - psycopg3 support for `copy_update`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetzkolchose%2Fdjango-fast-update","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetzkolchose%2Fdjango-fast-update","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetzkolchose%2Fdjango-fast-update/lists"}