How we sped up the document tree in WikiMind
In WikiMind, we built a cached JSON tree for document structure: collections → documents → subdocuments. Now the cache updates immediately, and rendering the tree no longer requires recursive SQL queries.

In WikiMind, we built a cached JSON tree for document structure: collections → documents → subdocuments. Now, whenever the structure changes, the cache is updated immediately, and rendering the tree no longer requires recursive SQL queries.
Why do this at all? When you have hundreds of collections and thousands of documents, recursive SQL quickly turns into that familiar “well, the database needs a moment to think...”. And if you add drag-and-drop on top of that, things start to smell like pain.
We made it so that dragging nodes stays fast, and soft delete and restore are applied recursively to the entire subtree. In other words, delete a parent — the children go away too, restore it — they all come back as well.
In practice, we moved complexity from reads to structure updates. For modern data-heavy products, that’s almost standard: less latency, less database load, and more happiness for both users and us ☕️