Opened 3 years ago

Last modified 2 years ago

#27236 assigned Cleanup/optimization

Deprecate Model.Meta.index_together in favour of Model.Meta.indexes

Reported by: Akshesh Doshi Owned by: Olivier Tabone
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords: index_together
Cc: olivier.tabone@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no


Anything that index_together does can be done by indexes and the Index class.

Change History (11)

comment:1 Changed 3 years ago by Akshesh Doshi

This ticket tracks a sub-part of this deprecation process -

comment:2 Changed 2 years ago by Tim Graham

Triage Stage: UnreviewedAccepted
Version: master

My understanding is that we're keeping the AlterIndexTogether migration operation around indefinitely for support in historical migrations. Are there any other details from our conversations to add?

comment:3 Changed 2 years ago by Akshesh Doshi

Keywords: db-indexes index_together removed

Yes, since AlterIndexTogether is currently there in the migrations of so many Django projects we need to keep maintaining it. But the idea is to deprecate the use of index_together in the models file and the generate_altered_index_together method of the MigrationAutodetector.

comment:4 Changed 2 years ago by Akshesh Doshi

Keywords: index_together added

Changed the keywords by mistake.

comment:5 Changed 2 years ago by Olivier Tabone

Cc: olivier.tabone@… added
Owner: changed from nobody to Olivier Tabone
Status: newassigned

working on this ticket during duth sprint

comment:6 Changed 2 years ago by Olivier Tabone


any comment appreciated

comment:7 Changed 2 years ago by Olivier Tabone

Has patch: set

comment:8 Changed 2 years ago by Tim Graham

Patch needs improvement: set

I left comments for improvement.

comment:9 Changed 2 years ago by Markus Holtermann

While this is the one step of the deprecation process of index_together there is currently no way to migrate an existing from index_together to indexes w/o dropping and recreating indexes. Since removing and adding an index can be a quite expensive operation, this is not an option to do so for now.

The next step in the deprecation process needs to treat indexes and index_together similarly in the sense that the latter is translated into the former internally (inside the migration framework). Once this is done, the deprecation of actually using index_together can start.

comment:10 Changed 2 years ago by Olivier Tabone

Hi Markus, Thank you for your reply.

Are you referring to #27064 ? or is it something different ?

comment:11 Changed 2 years ago by Tim Graham

I think that's the correct ticket.

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