论坛的嵌套数据
我自己陷入困境......
我们在嵌套集模型中左右限制来存储论坛帖子,我需要选择按最新回复排序的线程。
相关的表结构:
id lft rght date
1 1 4 2011-01-01
2 5 8 2011-01-02
3 6 7 2011-01-04
4 2 3 2011-01-05
因此我需要获得
id last_reply latest
1 4 2011-01-05
2 6 2011-01-04
任何帮助将非常感激。
Got myself stuck...
Us left and right limits in nested set model to store forum posts and I need to select threads ordered by latest reply.
Relevant table structure:
id lft rght date
1 1 4 2011-01-01
2 5 8 2011-01-02
3 6 7 2011-01-04
4 2 3 2011-01-05
so from that I need to get
id last_reply latest
1 4 2011-01-05
2 6 2011-01-04
any help would be very much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嵌套集不利于选择深度级别,因此效率不高。
我建议将线程启动的
id
与每个帖子一起存储,并在(starter, date)
上创建一个复合索引。这样,你就可以使用:
,这样会快得多。
Nested sets is not good for selecting the depth level so this is not going to be efficient.
I would suggest storing the thread started
id
along with each post and create a composite index on(starter, date)
.This way, you could just use:
which would be much faster.