5 ms·
To toot my own horn, I wrote a blog post that takes their approach and extends it to sort sibling comments by upvotes, like on HN or Reddit: http://illuminated
by pjungwir 12y ago
To toot my own horn, I wrote a blog post that takes their approach and extends it to sort sibling comments by upvotes, like on HN or Reddit:
http://illuminatedcomputing.com/posts/2014/09/postgres-cte-for-threaded-comments/ http://illuminatedcomputing.com/posts/2014/09/postgres-cte-f...
It's trickier than you might expect!
- Gracana 12y agoOh awesome, my solution to that is pretty similar. I also added a couple window functions in the final SELECT statement to get each comment's sibling count and position, which my application code uses to do pagination. It's definitely very puzzle-y stuff. Time consuming, but fun when you get a nice solution!