V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
simonlu9
V2EX  ›  程序员

社交共同好友要怎么现在比较好,现在想到用 neo4j 实现,成本有点大

  •  
  •   simonlu9 · 2021-11-02 19:19:48 +08:00 · 1640 次点击
    这是一个创建于 877 天前的主题,其中的信息可能已经有所发展或是发生改变。

    求问 v 友有什么好的办法

    7 条回复    2022-02-07 16:13:45 +08:00
    xuanbg
        1
    xuanbg  
       2021-11-03 08:32:10 +08:00
    共同好友不是一句 sql 就查出来了吗? select friend_id, friend_name from relation_table where user_id in (xxx, yyy) group by friend_id having count(*) > 1;
    AmaQuinton
        2
    AmaQuinton  
       2021-11-03 08:35:15 +08:00
    用 redis 实现
    simonlu9
        3
    simonlu9  
    OP
       2021-11-03 10:02:34 +08:00
    @xuanbg 不是查一个人,要查多个人
    xuanbg
        4
    xuanbg  
       2021-11-03 10:32:49 +08:00
    共同好友不就是 xxx 和 yyy 的好友的交集吗?
    x940727
        5
    x940727  
       2021-11-03 10:45:38 +08:00
    一楼正解,既是 A 的好友又是 B 的好友就是共同好友了。
    strawberryBug
        6
    strawberryBug  
       2021-11-03 12:45:32 +08:00
    图数据库查询多度好友很快的
    shinyzhu
        7
    shinyzhu  
       2022-02-07 16:13:45 +08:00
    说说用 Neo4j 的成本在哪里?感兴趣:)
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4130 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 05:24 · PVG 13:24 · LAX 22:24 · JFK 01:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.