投稿には次のスキーマがあります。各投稿には、作成者と添付ファイル (一連のリンク、動画、写真など) が埋め込まれています。
{
"content": "Pixable tempts Everpix users with quick-import tool for photos ahead of December 15 closure http:\/\/t.co\/tbsSrVYneK by @psawers",
"author": {
"username": "TheNextWeb",
"id": "10876852",
"name": "The Next Web",
"photo": "https:\/\/pbs.twimg.com\/profile_images\/378800000147133877\/895fa7d3daeed8d32b7c089d9b3e976e_bigger.png",
"url": "https:\/\/twitter.com\/account\/redirect_by_id?id=10876852",
"description": "",
"serviceName": "twitter"
},
"attachments": [
{
"title": "Pixable tempts Everpix users with quick-import tool for photos ahead of December 15 closure",
"description": "Pixable, the SingTel-owned company that organizes your social photos in smart ways, has announced a quick-import tool for Everpix users following the company's decision to close ...",
"url": "http:\/\/t.co\/tbsSrVYneK",
"type": "link",
"photo": "http:\/\/cdn1.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2013\/09\/camera1-.jpg"
}
]
}
投稿は頻繁に読まれます (4 つのタブを持つビューがあり、各タブには 24 の投稿が表示される必要があります)。現在、これらのリストのインデックスを Redis で作成しているため、4x24posts のクエリは、Redis からリストを取得し (mongo ID のリストを返します)、ID を使用して投稿をクエリするのと同じくらい簡単です。
埋め込まれた作成者の更新はめったに行われません (たとえば、作成者が自分の写真を変更した場合など)。更新は瞬時である必要はなく、高速である必要さえありません。
著者と投稿を 2 つの異なるコレクションに分割する必要があるかどうか疑問に思っています。したがって、投稿には、埋め込み/複製された作成者ではなく、作成者への参照が含まれます。ここでは、正規化されたデータ状態が優先されますか (著者は投稿ごとに複製され、多くの複製データ/余分なバイトが発生します)? それとも、非正規化状態を継続する必要がありますか?