Opened 6 years ago
Last modified 9 days ago
#29771 assigned Cleanup/optimization
Support database-specific syntax for bulk_update
Description ¶
As Simon points out here (https://code.djangoproject.com/ticket/23646#comment:15) specialized syntax can massively speed up bulk_update()
.
Postgres supports using UPDATE ... FROM
(https://stackoverflow.com/questions/18797608/update-multiple-rows-in-same-query-using-postgresql) and we can possibly emulate this with MySQL and UNION ...
's.
According to the ticket's flags, the next step(s) to move this issue forward are:
- To provide a patch by sending a pull request. Claim the ticket when you start working so that someone else doesn't duplicate effort. Before sending a pull request, review your work against the patch review checklist. Check the "Has patch" flag on the ticket after sending a pull request and include a link to the pull request in the ticket comment when making that update. The usual format is:
[https://github.com/django/django/pull/#### PR]
.
Change History (12)
comment:1 by , 6 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 6 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 6 years ago
Cc: | added |
---|
comment:4 by , 6 years ago
Cc: | added |
---|
comment:5 by , 6 years ago
Cc: | added |
---|
comment:6 by , 5 years ago
Cc: | added |
---|
comment:7 by , 5 years ago
Cc: | added |
---|
comment:8 by , 2 years ago
Owner: | removed |
---|---|
Status: | assigned → new |
comment:9 by , 16 months ago
Cc: | added |
---|
comment:10 by , 16 months ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:11 by , 15 months ago
Cc: | added |
---|
comment:12 by , 9 days ago
Cc: | added |
---|
Note:
See TracTickets
for help on using tickets.
I think the groundwork to this is quite difficult to lay. The current
SQLUpdateCompiler
is not suitable for this, I think.Also I believe we can mimic this on SQLLite:
Whether or not this is faster is something I'm not sure of. I believe the MySQL syntax will be faster, and there is no SQL standard way of doing this (I believe?), so we are left with a number of pretty different workarounds. I'm not sure how to structure this nicely.
I can maybe hack Postgres support into the SQLUpdateCompiler, but it's really not nice. We have to create all the aliases ourselves, manage the different column names, etc etc.