#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
-------------------------------------+-------------------------------------

Comment (by peterlauri):

 Replying to [comment:2 timgraham]:
 > Could you give some performance numbers for comparison?

 I prepped a DB with some fields and 500k rows. The alter table statements
 as in my original description executed each in few milliseconds. No
 significant improvement to execute them in a single statement.

 {{{
 ballongen=# select count(*) from testtable;
  count
 --------
  500000
 (1 row)

 Time: 34.261 ms
 ballongen=# ALTER TABLE "testtable" ADD COLUMN "field2" varchar(100) NULL;
 ALTER TABLE
 Time: 56.649 ms
 ballongen=# ALTER TABLE "testtable" ALTER COLUMN "field2" DROP DEFAULT;
 ALTER TABLE
 Time: 2.563 ms
 ballongen=# ALTER TABLE "testtable" ADD COLUMN "field3" varchar(100) NULL;
 ALTER TABLE
 Time: 1.165 ms
 ballongen=# ALTER TABLE "testtable" ALTER COLUMN "field3" DROP DEFAULT;
 ALTER TABLE
 Time: 0.240 ms
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24203#comment:7>
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.30f8f051c10c66151a3524195eb9cd5a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to