考虑我们有 Vertex User、Post 和 Edge FriendsWith、HasPost。FriendsWith 可以在两个方向上进出(通常是出或在两个用户之间)。用户是 Post 的所有者。
我们有 60 万用户和 7500 万个帖子
我用来获取用户朋友以下查询:
SELECT both('FriendsWith') FROM #12:1
并获得朋友的帖子
SELECT both('FriendsWith').out('HasPost') FROM #12:1 LIMIT 50
但是如果用户有很多朋友(~1000),性能不是最好的(约 400 毫秒获得朋友和 1-5 秒获得帖子)
有什么办法可以改善这个查询吗?
谢谢你。
更新
select from (select expand(both('FriendsWith').out('HasPost')) from #12:1) LIMIT 50
找到 50 个项目。查询在 7.08 秒内执行。