English 中文(简体)
• 在社会网络网站储存孟买邮局份额的有效途径?
原标题:Efficient way to store Shares of Posts in MongoDB on social networking site?

如标题所示,你称职。 员额有一个用户(作者)。 另一用户可以共用该员额。 员额还设有标记,其分类的标签有一系列的ids。 如何为快速检索储存?

使用案例:你有关系。 你从你的联系中看到员额,或从你的联系中获得的职位。 员额的“速度”由网页上订购。 共用员额可以继承和保持原有速度,也可以按自己的速度生活或死亡。 无法确定什么是最好的。

备选办法一:

Post {id :uniquePostId, userId: authorId, shares: [userIds of those who shared], tagIds: [tagIds for post]}

与这种方法有关的问题: Mongo没有给你指数化两个阵列。 因此,如果你想要对两面和股份进行盘问,那么问题就会缓慢。 两者的指数化几乎导致一个完整的表格扫描。

备选案文:

你重复这一员额:

Post {id: uniquePostId, userId: user who authored or shared the post, original: {postId: the original postId, or null if this is it, userId: the author of the original post}}

这种做法的问题: 请你抽出20个员额,以便询问用户 顺便提一下,你如何处理你关系中的重复份额? .。

Other approaches I ve read:

post: {
 shares_and_tags: [{type: share, id: 1}, {type: tag, id:4}, ...]
}

This seems to resolve the indexing problems, but I don t know enough about Mongo to know the performance implications here. Gonna do some testing shortly, but figured I d see if the community has any advice or experience. Thanks!

问题回答

OK, given the discussion in the comments:

这是在蒙戈布省获救后从垂直排出的二氧化物中提取的部分非必要数据,以简化实例。

{
    "_id" : ObjectId("4f2849353ac01aebf231408a"),
    "place" : null,
    "text" : "tweet text",
    "created_at" : "Tue Jan 31 20:04:05 +0000 2012",
    "retweet_count" : 0,
    "favorited" : false,
    "source" : "<a href="http://mobile.twitter.com" rel="nofollow">Mobile Web</a>",
    "in_reply_to_screen_name" : null,
    "in_reply_to_user_id" : null,
    "retweeted" : false,
    "in_reply_to_status_id" : null,
    "in_reply_to_status_id_str" : null,
    "id_str" : "123456767800304",
    "user" : {
    },
    "truncated" : false,
    "id" : NumberLong("1234567890"),
    "in_reply_to_user_id_str" : null,
    "entities" : {
        "hashtags" : [ ],
        "user_mentions" : [ ],
        "urls" : [ ]
    }
}

As you can see, each tweet is stored as a new tweet. If this was a re-tweet, it would have the retweeted flag set to true and have the id of the post it was a response to as well as the user it was in response to referenced in the top level fields.





相关问题
Problem with Insoshi install script and mysql

i have a problem regarding the installation of Insoshi. I followed the insallation instructions in the Readme file of Insoshi. My problems occur when i try to run "script/install" The readme file ...

Google Social Graph API, working as intended?

I m experiencing some problems with Google s social graph API. It seems that for some parameters passed to otherme nothing is returned. I ll use Robert Scoble s profiles as an example (as he s a guy ...

热门标签