V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐工具
RoboMongo
推荐书目
50 Tips and Tricks for MongoDB Developers
Related Blogs
Snail in a Turtleneck
family
V2EX  ›  MongoDB

embedded document可以提高效率,但一致性一定会牺牲?

  •  
  •   family · 2013-11-29 16:16:24 +08:00 · 3490 次点击
    这是一个创建于 3802 天前的主题,其中的信息可能已经有所发展或是发生改变。
    comment: {
    _id: ObjectId("52983d2140e7b4c7220041ab"),
    body: "xxx",
    last_comment: {
    $ref: "comment",
    $id: ObjectId("529844f240e7b4f8000041cb"),
    $db: "test"
    },
    user: {
    $ref: "user",
    $id: ObjectId("5295afb940e7b4f8000041a7"),
    $db: "test"
    }
    }

    这是引用形式,当获取这个comment时,需要查询一次user,last_comment,如果还需要last_comment的user,一共需要4次查询,但如果使用embedded,虽然文档大一些,但效率提高了,但是一致性怎么解决呢?比如user信息更新了,修改了last_comment指向的comment,不知道怎么解决?
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   879 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 21:06 · PVG 05:06 · LAX 14:06 · JFK 17:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.