Opened 9 years ago

Closed 9 years ago

#25892 closed Cleanup/optimization (fixed)

Optimize SeparateDatabaseAndState.database_backwards() by caching intermediate state

Reported by: Amos Onn Owned by: Amos Onn
Component: Migrations Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Amos Onn)

The database_backwards of SeparateDatabaseAndState runs at O(n2) where n is the number of database_operations. For each operation, it regenerates the state up to it from the first operation. Instead, we could cache all the intermediate states, similar to the implementation of _migrate_all_backwards in the migration executor (or migrate in django 1.8.x).

Change History (4)

comment:1 by Amos Onn, 9 years ago

Description: modified (diff)
Status: newassigned

comment:2 by Tim Graham, 9 years ago

Summary: SeparateDatabaseAndState database_backwards is slow.Optimize SeparateDatabaseAndState.database_backwards() by caching intermediate state
Triage Stage: UnreviewedAccepted

comment:3 by Tim Graham, 9 years ago

Has patch: set

comment:4 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In bd3c2900:

Fixed #25892 -- Optimized SeparateDatabaseAndState.database_backwards().

Now intermediate states in the database_backwards are cached, similar to
the executor's migrate() (or _migrate_all_backwards()). This makes the
migration run much faster (O(n) instead of O(n2) over number of
database_operations).

Note: See TracTickets for help on using tickets.
Back to Top