Ticket #941 (reopened defect)
add_column does unnecessary (and db-blocking) work
|Reported by:||Gábor Farkas <gabor.farkas@…>||Owned by:||andrew|
when south adds a field, it does 2 alter-table commands, the second one is often unnecessary and very slow.
in more detail:
when doing this:
db.add_column('p_thing', 'content', self.gf('django.db.models.fields.CharField')(max_length=30, null=True), keep_default=False)
the following 2 commands are executed:
ALTER TABLE "p_thing" ADD COLUMN "content" varchar(30) NULL; ALTER TABLE "p_thing" ALTER COLUMN "content" TYPE varchar(30), ALTER COLUMN "content" DROP NOT NULL, ALTER COLUMN "content" DROP DEFAULT;
the second command is totally unnecessary: the type is already correct, it is not "NOT NULL", and it does not have a DEFAULT.
the bigger problem is that when doing this on a db in production, the first commands finishes very fast, but the second one takes a very long time (i guess it does something to every row). so the migration will block the site's normal traffic for a very long time.
- Status changed from new to closed
- Resolution set to wontfix
- Status changed from closed to reopened
- Resolution wontfix deleted
- Milestone set to The Future