Re: [Django] #34534: Reduce index/constraints operations.

17 views
Skip to first unread message

Django

unread,
May 3, 2023, 8:31:10 AM5/3/23
to django-...@googlegroups.com
#34534: Reduce index/constraints operations.
--------------------------------------+------------------------------------
Reporter: David Sanders | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Description changed by Mariusz Felisiak:

Old description:

> From https://github.com/django/django/pull/16819#issuecomment-1529913703
>
> - RenameIndex can be reduced into CreateIndex
> - DropConstraint can be reduced into CreateConstraint
> - 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

New description:

From https://github.com/django/django/pull/16819#issuecomment-1529913703

- `RenameIndex` can be reduced into `AddIndex`
- `DropConstraint` can be reduced with `AddConstraint`
- 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

--

--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 8, 2023, 3:41:06 AM5/8/23
to django-...@googlegroups.com
#34534: Reduce index/constraints operations.
-------------------------------------+-------------------------------------
Reporter: David Sanders | Owner: Akash
Type: | Kumar Sen
Cleanup/optimization | Status: assigned

Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Akash Kumar Sen):

* owner: nobody => Akash Kumar Sen
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:3>

Django

unread,
May 8, 2023, 6:51:52 AM5/8/23
to django-...@googlegroups.com
#34534: Reduce index/constraints operations.
-------------------------------------+-------------------------------------
Reporter: David Sanders | Owner: Akash
Type: | Kumar Sen
Cleanup/optimization | Status: assigned
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by David Sanders):

Hi Akash,

Please see this PR for context & "prior art":
https://github.com/django/django/pull/16819 👍

--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:4>

Django

unread,
May 8, 2023, 9:44:35 PM5/8/23
to django-...@googlegroups.com
#34534: Reduce index/constraints operations.
-------------------------------------+-------------------------------------
Reporter: David Sanders | Owner: Akash
Type: | Kumar Sen
Cleanup/optimization | Status: assigned
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by David Sanders):

* needs_better_patch: 0 => 1
* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:5>

Django

unread,
May 9, 2023, 12:58:31 AM5/9/23
to django-...@googlegroups.com
#34534: Reduce index/constraints operations.
-------------------------------------+-------------------------------------
Reporter: David Sanders | Owner: Akash
Type: | Kumar Sen
Cleanup/optimization | Status: assigned
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Akash Kumar Sen):

Thanks for the review David. Updated the patch accordingly.

--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:6>

Django

unread,
May 9, 2023, 5:48:30 AM5/9/23
to django-...@googlegroups.com
#34534: Reduce index/constraints operations.
-------------------------------------+-------------------------------------
Reporter: David Sanders | Owner: Akash
Type: | Kumar Sen
Cleanup/optimization | Status: assigned
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:7>

Django

unread,
May 9, 2023, 11:54:53 AM5/9/23
to django-...@googlegroups.com
#34534: Reduce index/constraints operations.
-------------------------------------+-------------------------------------
Reporter: David Sanders | Owner: Akash
Type: | Kumar Sen
Cleanup/optimization | Status: assigned
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"92f0017133c2d31fbd527bab7b08d4d49a582143" 92f0017]:
{{{
#!CommitTicketReference repository=""
revision="92f0017133c2d31fbd527bab7b08d4d49a582143"
Refs #34534 -- Reduced Add/RemoveConstraint and Add/RenameIndex operations
when optimizing migrations.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:8>

Django

unread,
May 9, 2023, 11:55:08 AM5/9/23
to django-...@googlegroups.com
#34534: Reduce index/constraints operations.
-------------------------------------+-------------------------------------
Reporter: David Sanders | Owner: Akash
Type: | Kumar Sen
Cleanup/optimization | Status: assigned
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* has_patch: 1 => 0
* stage: Ready for checkin => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:9>

Django

unread,
May 25, 2023, 3:17:49 AM5/25/23
to django-...@googlegroups.com
#34534: Reduce index/constraints operations.
--------------------------------------+------------------------------------
Reporter: David Sanders | Owner: (none)
Type: Cleanup/optimization | Status: new

Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* owner: Akash Kumar Sen => (none)
* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:10>

Django

unread,
May 26, 2023, 5:18:04 PM5/26/23
to django-...@googlegroups.com
#34534: Reduce index/constraints operations.
--------------------------------------+------------------------------------
Reporter: David Sanders | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Adam Johnson):

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:11>

Django

unread,
Jan 30, 2024, 12:23:26 PM1/30/24
to django-...@googlegroups.com
#34534: Reduce index/constraints operations.
--------------------------------------+------------------------------------
Reporter: David Sanders | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by bcail):

* cc: bcail (added)

Comment:

Should this ticket be closed, or is there something else that's supposed
to be done here?
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:12>

Django

unread,
Jan 30, 2024, 2:43:17 PM1/30/24
to django-...@googlegroups.com
#34534: Reduce index/constraints operations.
--------------------------------------+------------------------------------
Reporter: David Sanders | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by Mariusz Felisiak):

Replying to [comment:12 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

--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:13>

Django

unread,
Jan 31, 2024, 3:42:20 PM1/31/24
to django-...@googlegroups.com
#34534: Reduce index/constraints operations.
--------------------------------------+------------------------------------
Reporter: David Sanders | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by bcail):

> A question was raised whether constraints could be reduced into create
model though some databases do not support deferrable constraints (eg
MySQL)

I opened [https://github.com/django/django/pull/17805 a PR] for this part.
Is that on the right track?
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:14>

Django

unread,
Feb 1, 2024, 10:34:31 AM2/1/24
to django-...@googlegroups.com
#34534: Reduce index/constraints operations.
--------------------------------------+------------------------------------
Reporter: David Sanders | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by bcail):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:15>

Django

unread,
Feb 1, 2024, 4:30:33 PM2/1/24
to django-...@googlegroups.com
#34534: Reduce index/constraints operations.
--------------------------------------+------------------------------------
Reporter: David Sanders | Owner: bcail
Type: Cleanup/optimization | Status: assigned

Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by bcail):

* owner: (none) => bcail


* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:16>

Django

unread,
Feb 9, 2024, 1:08:18 AM2/9/24
to django-...@googlegroups.com
#34534: Reduce index/constraints operations.
-------------------------------------+-------------------------------------
Reporter: David Sanders | Owner: bcail
Type: | Status: assigned
Cleanup/optimization |

Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:17>

Django

unread,
Feb 9, 2024, 2:06:22 AM2/9/24
to django-...@googlegroups.com
#34534: Reduce index/constraints operations.
-------------------------------------+-------------------------------------
Reporter: David Sanders | Owner: bcail
Type: | Status: assigned
Cleanup/optimization |
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"8b7ddd1b621e1396cf87c08faf11937732f09dcd" 8b7ddd1]:
{{{#!CommitTicketReference repository=""
revision="8b7ddd1b621e1396cf87c08faf11937732f09dcd"
Refs #34534 -- Reduced constraint operations with Meta.constraints when
optimizing migrations.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:18>

Django

unread,
Feb 9, 2024, 2:08:13 AM2/9/24
to django-...@googlegroups.com
#34534: Reduce index/constraints operations.
-------------------------------------+-------------------------------------
Reporter: David Sanders | Owner: bcail
Type: | Status: closed

Cleanup/optimization |
Component: Migrations | Version: dev
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: assigned => closed
* resolution: => fixed

--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:19>

Reply all
Reply to author
Forward
0 new messages