I'm using flask SQLAlchemy-MPTT
https://sqlalchemy-mptt.readthedocs.io/tut_flask.html in one of my project as the data is hierarchical in nature, And the rebuild_tree
operation in SQLAlchemy-MPTT
(Modified Preorder Tree Traversal) is responsible for updating the tree structure based on the parent-child relationships in the database.
While testing locally with up to 10 trees it is no performance issue at all, but I'm concerned when there are 100s of trees in my db, and I'm calling the rebuild command (which will rebuild all 100s of trees), this might be a significant performance issue.
Actual Behavior:
The rebuild_tree
operation is taking an unreasonably long time, especially noticeable when dealing with larger datasets, adversely affecting the overall performance of the library.
Expected Behavior:
The rebuild_tree
operation should complete within a reasonable time frame, even as the size of the dataset grows.
Anybody out there who has experience with using the rebuild command?
This is how I'm calling rebuild_tree to update the left, right of a tree
MyModel.rebuild_tree(db.session, root_.tree_id) # rebuild lft, rgt value automatically db.session.commit()
but for larger datasets it's taking too much of time,