#24203: Optimisation: adding multiple fields to same model should attempt to run
single ALTER TABLE statement
-------------------------------------+-------------------------------------
Reporter: peterlauri | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: migration | Triage Stage:
| Someday/Maybe
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by MarkusH):
* cc: MarkusH (added)
* version: 1.7 => master
* stage: Unreviewed => Someday/Maybe
Comment:
On PG it is recommended (in the docs iirc, but can't find a link) to add a
column with `null=True`, promote the row values for existing rows and drop
the `not null` constraint. This way adding the column is instant and thus
no need to join multiple `AddField` operations.
On MySQL <5.6 the `ADD COLUMN` operations are expensive in any case
independent from `NULL` or `NOT NULL` afaik.
On SQLite, well, it's SQLite. It's slow anyways and doesn't support adding
multiple columns at once.
I have no clue about Oracle's behavior.
That said, I'm not sure this is really necessary but keep the issue open
for your feedback.
--
Ticket URL: <https://code.djangoproject.com/ticket/24203#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.4e7d69604dc371c3ba408b9b0f705139%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.