mongodb – separate document vs. embedded document

  • no big difference for insert and update
  • So, separate collections are good if you need to select individual documents, need more control over querying, or have huge documents.

    Embedded documents are good when you want the entire document, the document with a $slice of comments, or with no comments at all.

  • As a general rule, if you have a lot of “comments” or if they are large, a separate collection might be best.

    Smaller and/or fewer documents tend to be a natural fit for embedding.

This entry was posted in DB. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s