MONGODB Best Practices

来源:互联网 发布:js 分享到qq空间 编辑:程序博客网 时间:2024/05/02 04:53

Summary of Best Practices

  • "First class" objects, that are at top level, typically have their own collection.
  • Line item detail objects typically are embedded.
  • Objects which follow an object modelling "contains" relationship should generally be embedded.
  • Many to many relationships are generally done by linking.
  • Collections with only a few objects may safely exist as separate collections, as the whole collection is quickly cached in application server memory.
  • Embedded objects are a bit harder to link to than "top level" objects in collections.
  • It is more difficult to get a system-level view for embedded objects. When needed an operation of this sort is performed by using MongoDB's map/reduce facility.
  • If the amount of data to embed is huge (many megabytes), you may reach the limit on size of a single object. See alsoGridFS.
  • If performance is an issue, embed.
原创粉丝点击