#33848: Migration StateApps.clone deepcopy too many objects
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Migrations | Version: 4.0
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Iuri de Silvio:
Old description:
> `StateApps.clone` execute two slow deep copies. The first one copy all
> models. The second one copy app configs, that include all apps and the
> specific app models.
>
> In my application, with ~250 models, this deepcopy is around 5% of
> migration time. I was able to cleanup `StateApps` before copy, to not
> copy all models and apps every operation again.
>
> https://github.com/django/django/blob/d4c5d2b52c897ccc07f04482d3f42f976a79223c/django/db/migrations/state.py#L683
New description:
`StateApps.clone` execute two slow deep copies. The first one copy all
models. The second one copy app configs, that include all apps and the
specific app models.
In my application, with ~250 models, this deepcopy is around 5% of
migration time. I was able to cleanup `StateApps` before copy, to not copy
all models and apps every operation again. After the optimization, it
takes less than 1% of migration time.
https://github.com/django/django/blob/d4c5d2b52c897ccc07f04482d3f42f976a79223c/django/db/migrations/state.py#L683
--
--
Ticket URL: <https://code.djangoproject.com/ticket/33848#comment:1>
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 on the web visit
https://groups.google.com/d/msgid/django-updates/01070182040a6078-792d7cd6-29a5-44a0-a083-910965340391-000000%40eu-central-1.amazonses.com.