#36869: Optimise migration graph planning
-------------------------------------+-------------------------------------
     Reporter:  James Fysh           |                     Type:
                                     |  Cleanup/optimization
       Status:  new                  |                Component:  Database
                                     |  layer (models, ORM)
      Version:  dev                  |                 Severity:  Normal
     Keywords:  migration digraph    |             Triage Stage:
  loader                             |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
 When django needs to work with migrations - making & applying migrations,
 running checks - it loads available migrations from disk and builds up an
 in-memory digraph.

 The django project that I work on has managed to accumulate a large number
 of django apps and associated migrations.  I'm going to leave the obvious
 discussion around migration squashing out of this - let's just assume it
 is not practical to do in the near term.

 Anecdotally, starting the django application, eg. when running management
 commands or simply launching the server is noticeably slow.  Profiling has
 revealed that a significant portion of startup time is spent running
 migration checks.

 To cut a long story short, MigrationGraph._generate_plan() currently runs
 in O(n*n), and with a ~3 line patch we can reduce this to O(n).

 For small django projects I believe this will not result in any change in
 performance.  For large projects such as ours, this can result in a very
 significant reduction in startup time.  Given the nature of the change
 (simple and arguably low-risk) I think it would be a reasonable change to
 make.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36869>
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 view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019bc49f1816-d76d8dbd-7215-44e2-96bf-7c17cd0f9b4d-000000%40eu-central-1.amazonses.com.

Reply via email to