Restore missing SQL indexes for MPTT fields #11938

Open
opened 2025-12-29 21:51:44 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Dec 18, 2025).

Proposed Changes

All models which employ MPTT (from django-mptt) should have SQL indexes for ('tree_id', 'left'), however these are not created by the database migrations. This seems to have been partially solved by django-mptt/django-mptt#845 in v0.18.0, however the indexes are not automatically created for most models.

This was originally tracked under #20954 but has been split into a separate issue for investigation.

Justification

Adding these indexes should improve overall query performance for MPTT-enabled models.

Originally created by @jeremystretch on GitHub (Dec 18, 2025). ### Proposed Changes All models which employ MPTT (from `django-mptt`) should have SQL indexes for `('tree_id', 'left')`, however these are not created by the database migrations. This seems to have been partially solved by django-mptt/django-mptt#845 in v0.18.0, however the indexes are not automatically created for most models. This was originally tracked under #20954 but has been split into a separate issue for investigation. ### Justification Adding these indexes should improve overall query performance for MPTT-enabled models.
adam added the type: housekeepingnetbox labels 2025-12-29 21:51:44 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11938