Opened 6 years ago
Last modified 11 months ago
#29771 assigned Cleanup/optimization
Support database-specific syntax for bulk_update
Reported by: | Tom Forbes | Owned by: | Akash Kumar Sen |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Tom Forbes, Brillgen Developers, Srinivas Reddy Thatiparthy, Adam Johnson, Shai Berger, Akash Kumar Sen, John Speno | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
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.
Change History (11)
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 , 4 years ago
Cc: | added |
---|
comment:8 by , 19 months ago
Owner: | removed |
---|---|
Status: | assigned → new |
comment:9 by , 12 months ago
Cc: | added |
---|
comment:10 by , 12 months ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:11 by , 11 months 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.