5 ms·
Cool. I thought I was the only one that couldn't figure out a nice way to do threaded comments, turns out even reddit orders stuff in memory.
by petervandijck 16y ago
Cool. I thought I was the only one that couldn't figure out a nice way to do threaded comments, turns out even reddit orders stuff in memory.
- KERMIT 16y agoMaybe that's why reddit is so damn slow most of the time.
- iamelgringo 16y agoThreaded comments are surprisingly difficult to model in a relational database. I spent about a month on the problem when I rolled my own threaded comment system for newsley. Relational Databases really don't lend themselves to easily modeling tree structures. If you're interseted in doing something like this, I'd highly recommend this book: http://www.amazon.com/Hierarchies-Smarties-Kaufmann-Management-Systems/dp/1558609202/ref=sr_1_4?ie=UTF8&s=books&qid=1275227474&sr=8-4 http://www.amazon.com/Hierarchies-Smarties-Kaufmann-Manageme... He has two really good chapters that specifically building a comment system. It takes a bit of work, and you end up pre-computing the comment system on INSERT's instead of SELECT's. But, you can build a comment system that pulls your entire comment tree in order using a single SELECT ... FROM COMMENTS ... ORDER BY comment.node_left;