Skip to content

Evaluate replacing MPTT with PostgreSQL ltree #11421

@arthanson

Description

@arthanson

Proposed Changes

The recent loss of maintainership for django-mptt, has precipitated discussion on evaluating a replacement for our usage of MPTT for hierarchical models with an alternate solution. CTE has been discussed, see #6587

Author of django-tree-queries lists his reasons here: https://406.ch/writing/django-tree-queries/. He notes potential issues he doesn't like with PostgreSQL ltree, however this is probably still a viable alternative. See https://github.com/mariocesar/django-ltree and https://github.com/peopledoc/django-ltree-demo (the ltree-demo could just be pulled into the app and updated, i.e. not use any library). Potentially easier to implement the equivalent of add_related_count()...

Justification

MPTT has serves us pretty well, however it comes with some limitations, notably the need to consistently rebuild the tree with every change. This imposes some additional overhead around things like bulk updates. MPTT also requires a set of database fields to maintain the tree: tree_id, level, lft (left), and rght (right). There are also a handful of issues blocked by us making a decision on this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: acceptedThis issue has been accepted for implementationtype: housekeepingChanges to the application which do not directly impact the end user

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions