I need to include Carl Meyer's suggestions for using text in text . I am currently working on such a system, but with some further optimizations for the forums.
In forum systems that support answers, you often insert in the middle of the tree, which results in poor performance. To reduce the pain, I'm working on allowing spaces in a number line. This works as a preliminary allocation of memory in the list of arrays. The cost of switching the tree to the right is the same for 1 and 100. Therefore, with successive answers (which is more likely), I can update a smaller number of tree nodes, and they will be much faster.
Reduction is the count of descendant nodes (the number of responses below this message), comparing the current nodes on the left and right. This information can be cached in the data structure to do this quickly. Therefore, I will have to update all the ancestor nodes with the new values. Still fewer nodes will be updated, and the result will be much faster than the average insert insert time.
Several trees are stored in one table. Each tree has a unique tree identifier, one per topic. Smaller trees update much faster.
Hope this helps
source share