#26407: Investigate applying transitive reduction to migration graph.
-------------------------------------+-------------------------------------
     Reporter:  jarekwg              |      Owner:  nobody
         Type:                       |     Status:  new
  Cleanup/optimization               |
    Component:  Migrations           |    Version:  master
     Severity:  Normal               |   Keywords:  transitive reduction
                                     |  showmigrations
 Triage Stage:  Unreviewed           |  Has patch:  0
Easy pickings:  0                    |      UI/UX:  0
-------------------------------------+-------------------------------------
 This stemmed from a discussion between @markush and myself in
 [https://github.com/django/django/pull/6254].

 We should investigate migration loading performance for the following:
 - Requiring the migration graph to always have the minimum number of
 edges. This would mean enforcing transitive reduction whenever a new edge
 is added. This would be a trade off between the additional computation to
 ensure the graph is minimal versus the reduced computation in traversing
 the graph for ancestors/descendants/etc.
 - Performing a single transitive reduction step once the graph has been
 built. Again, this would be to simplify any later traversal.

 Closely related to this is the `showmigrations` command, with the `--plan`
 flag at verbosity 2. This adds a lists of migration dependencies in
 brackets next to every migration in the plan. Currently each list of
 dependencies is constructed from the original `Migration` object's
 `dependencies` list, with:
 - appropriate replacements made for migrations that have been replaced by
 squash migrations, and
 - additional dependencies added based on any `run_before` declarations.
 So what this shows is the list of dependencies, somewhat rawly, as set by
 the user in their migration files. If the user declares redundant
 dependencies, then these bleed into the migration graph, which propagates
 to the list of dependencies printed by `showmigrations`. The question is
 what do we want it to show? This raw list may help the user with
 debugging, but it could get cluttered if there is an abundance of
 superfluous dependencies. So what we could do is print dependencies that
 come from the migration graph after it has been transitively reduced. This
 would improve the brevity, though whether it would be helpful to the user
 is up for debate. We could also try using both reduced and unreduced
 migration graphs to emphasise superfluous dependencies to the user.

 TLDR:
 1) Investigate migration performance with transitive reduction:
 - at every edge addition
 - after graph is built

 2) Decide what would be most useful to list for `showmigrations --plan
 -v2`:
 - [current] Raw dependencies (with changes to account for replacements and
 `run_before`).
 - Only critical dependencies (by using reduced graph).
 - Raw dependencies with superfluous edges somehow emphasised.

 To be clear, I don't see a problem with the current system, but thought
 this might be worth investigating/discussing.

--
Ticket URL: <https://code.djangoproject.com/ticket/26407>
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/050.e39ef51c8b5ceca28cf1158508c6c7b8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to