laravel-nestedset
laravel-nestedset copied to clipboard
Efficiently restrict number of levels when using descendants()
For really big trees (say 100k nodes in 5+ levels), descendants() will return all those nodes and will break the application. The subquery added by withDepth() is costly the more nodes the tree has. Did you thought about adding a level column for that reason? This would speed up retrieving e.g. only the first three levels in a 100k node tree drastically.