Opened 2 years ago
Closed 21 months ago
#34534 closed Cleanup/optimization (fixed)
Reduce index/constraints operations.
| Reported by: | David Sanders | Owned by: | bcail |
|---|---|---|---|
| Component: | Migrations | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | bcail | Triage Stage: | Ready for checkin |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
From https://github.com/django/django/pull/16819#issuecomment-1529913703
RenameIndexcan be reduced intoAddIndexDropConstraintcan be reduced withAddConstraint- A question was raised whether constraints could be reduced into create model though some databases do not support deferrable constraints (eg MySQL)
- It's worth going over the operations to see if there are any other potential reductions to add
Change History (19)
comment:1 by , 2 years ago
| Component: | Database layer (models, ORM) → Migrations |
|---|---|
| Easy pickings: | unset |
| Summary: | Migration operation optimisations → Reduce index/constraints operations. |
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 2 years ago
| Description: | modified (diff) |
|---|
comment:3 by , 2 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:4 by , 2 years ago
Hi Akash,
Please see this PR for context & "prior art": https://github.com/django/django/pull/16819 👍
comment:5 by , 2 years ago
| Has patch: | set |
|---|---|
| Patch needs improvement: | set |
comment:7 by , 2 years ago
| Patch needs improvement: | unset |
|---|---|
| Triage Stage: | Accepted → Ready for checkin |
comment:9 by , 2 years ago
| Has patch: | unset |
|---|---|
| Triage Stage: | Ready for checkin → Accepted |
comment:10 by , 2 years ago
| Owner: | removed |
|---|---|
| Status: | assigned → new |
comment:11 by , 2 years ago
Thank you for reporting this David, making the PR Akash, and reviewing Mariusz. 👏
I was just looking at a migration with consecutive add + remove operations for the same constraints, wondering why they weren't optimized. Glad to see they will be in the future.
follow-up: 13 comment:12 by , 21 months ago
| Cc: | added |
|---|
Should this ticket be closed, or is there something else that's supposed to be done here?
comment:13 by , 21 months ago
Replying to bcail:
Should this ticket be closed, or is there something else that's supposed to be done here?
Two points remain unresolved:
- A question was raised whether constraints could be reduced into create model though some databases do not support deferrable constraints (eg MySQL)
- It's worth going over the operations to see if there are any other potential reductions to add
comment:14 by , 21 months ago
A question was raised whether constraints could be reduced into create model though some databases do not support deferrable constraints (eg MySQL)
I opened a PR for this part. Is that on the right track?
comment:15 by , 21 months ago
| Has patch: | set |
|---|
comment:16 by , 21 months ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
comment:17 by , 21 months ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
comment:19 by , 21 months ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Thanks for the ticket.
This point it too generic. Please open a new ticket when you will find something more. We don't want to keep this ticket to be open forever.