Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6031379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:10:31+00:00 2026-05-23T05:10:31+00:00

I read that embedding is better from a performance point of view: If performance

  • 0

I read that embedding is better from a performance point of view:
“If performance is an issue, embed.” (http://www.mongodb.org/display/DOCS/Schema+Design) and most guides always say contains should be embedded.

However I am not sure this is the case. Suppose we have two objects: Blog and Post. Blog contains posts.

Now making all posts embedded in blog will have the following issues:

  1. Paging. Since it’s not possible to filter embedded objects, we will always get all posts and need to filter them out in the application.
  2. Filtering. Same as before, when searching for word inside posts, it will not be possible to filter the embedded collection from MongoDB.
  3. Insert. I assume inserting to collection is faster than inserting to embedded object. Is this correct? this is written anywhere?
  4. Update. Same as before, inline updating field inside smaller document (Post) might be faster then inline updating the post inside big document of Blog. Is this correct?

Taking all of the above, I would go for having posts in a separate collection referencing Blog. Is this the correct conclusion?

(Note: Please do not factor document size limit in the response, let’s assume each blog will have at most 1000 posts)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:10:32+00:00Added an answer on May 23, 2026 at 5:10 am

    1.Paging possible with $slice operator:

    db.blogs.find({}, {posts:{$slice: [10, 10]}}) // skip 10, limit 10
    

    2.Filtering also possible:

    db.blogs.find({"posts.title":"Mongodb!"}, {posts:{$slice: 1}}) //take one post
    

    3,4. Generally i guess you are speaking about small performance difference. It’s not rocket science, it just blog with at most 1000 posts.

    You said:

    Is this the correct conclusion?
    

    No, if you care about performance (in general if system will be small you can go with separate document).

    I’ve done small performance test regarding 3,4, here is results:

    -----------------------------------------------------------------
    | Count/Time |  Inserting posts   | Adding to nested collection |
    -------------|--------------------------------------------------               
    |   1        |   1 ms             |  28 ms                      |
    |   1000     |   81 ms            |  590 ms                     |
    |   10000    |   759 ms           |  2723 ms                    |
     ---------------------------------------------------------------
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read that you could call JavaScript code from a Java Applet by calling
I read that System.Drawing.Point is a value type. I do not understand. Why?
I read that this could improve the performance of XCode 4 which is running
From what I've read you can embed WebKit into your Android client application and
I read that MongoDB documents are limited to 4 MB in size. I also
I've recently read that embedding ruby inside JavaScript is not a good idea. However,
I read that there is a funciton called alloca that allocates memory from the
I read that Domain Driven Design is about concentrating on the problem domain instead
I read that SQL exceptions are treated as normal exceptions in managed SPs; I
I read that you should define your JavaScript functions in the <head> tag, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.