-
Notifications
You must be signed in to change notification settings - Fork 10
Heavy load methods
Anton Demushkin edited this page Apr 27, 2021
·
1 revision
Some methods of this library require level or parentId field. If you don't have any of the fields, they will be generated on the fly which may result in high load and slow work. A simple way to optimize this issue is to add one of columns or both:
-
level- int, not null. For its name you can also uselevelColumnNameoption. -
parentId- same asidcolumn type, nullable. You can use another column name usingparentIdColumnNameoption. Don't forget to set correctparentIdColumnTypeif youridis not an integer.
Here are the methods, conditions and possible optimizations (they may conflict, please choose the most applicable for you):
Model.fetchTree()record.getDescendants()-
record.getAncestors()- when:
depth> 0 and you don't uselevelfield - optimization: use
levelfield
- when:
-
record.getParent()- when:
depth> 0 and you don't uselevelfield - optimization: use
parentIdorlevelfield
- when:
-
record.insertAsParentOf()- when you use either
levelorparentId - optimization: don't use
parentIdandlevelfields
- when you use either