Opened 9 years ago
Last modified 9 years ago
#26693 closed Cleanup/optimization
RenameModel causes state.apps rendering leading to massive time increase in makemigrations — at Version 1
| Reported by: | Simon Percivall | Owned by: | nobody |
|---|---|---|---|
| Component: | Migrations | Version: | 1.10 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | yes | Patch needs improvement: | yes |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Not 100% sure I have complete understanding of what happens, or why, but it seems a RenameModel migration leads to an evaluation of state.apps, which affects the time it takes for it and all following migration states to be calculated.
This is for a pretty big app, with lots of migrations. The time to run makemigrations for all apps goes from 1 seconds to 77 seconds with one RenameModel migration.
A test where apps.state was replaced by temp_state = state.close(); apps = temp_state.apps resolved the issue, but I'm not completely sure of the side effects of doing that. (Or even better if it were possible to check immediately if 'apps' in state.__dict__ and skip the rendering completely.)