3 ms·
Am I missing something about the database section? It seems like if I add, e.g. a right child to node B in the diagram, I will have to update the "right" value
by epe 17y ago
Am I missing something about the database section? It seems like if I add, e.g. a right child to node B in the diagram, I will have to update the "right" values on nodes A & B, as well as both the "left" and "right" values on C & E. Imagine doing this with a much larger subtree where C is, and you're looking at a ton of UPDATEs to store one new node, aren't you?
- gecko 17y agoYes. The good news is that you read hierarchies much more often than you update them, and hierarchies in a bug tracker are going to be relatively tiny, so taking a minor write-hit in exchange for a massive read improvement is a logical trade.
- sanj 17y agoYou're exactly right. Any insert will end up incrementing every node on its right. Any deletion, will end up decrementing every node on its left. It's possible you could do the deletions silently, because you don't actually care about gaps. But I don't see any way around inserts being expensive.