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

  • SEARCH
  • Home
  • 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 8327709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:12:25+00:00 2026-06-09T01:12:25+00:00

This is a pretty common question on MongoDB: When to embed and when to

  • 0

This is a pretty common question on MongoDB: When to embed and when to reference.

However in my case, this appears to be somehow a dilemma. I have a document that have a reference where I could just embedded it, yet it will cost me the size of the disk. But if I make a reference, it will give me quite a performance cost.

Here’s an example, say I have this Member with the ‘detail’ as my problem:

Member: {
    _id: "abc",
    detail: {
        name: "Stack Overflow",
        website: "www.stackoverflow.com"
    }
}

I want this Member’s detail to be in every Blog this member “asdf” made cause every blog displayed would display the member details. So there are 2 options I can do for my Blog document:

First, make a reference by only putting the member’s _id:

Blog: {
    _id: 123,
    memberId: "asdf"  ---> will be used as reference to query specific member
}

or Second, embed the member into Blog instead:

Blog: {
    _id: 123,
    member: {
        _id: "asdf",
        detail: {
            name: "Stack Overflow",
            website: "www.stackoverflow.com"
        }
    }
}

So the first option requires another query for member which is a performance issue. The second option however is faster cause I only need to query once, yet my disk would get larger for redundant data of embedded document ‘member’ as the number of Blog grows.

PS: As you can see for this example, Member and Blog relationship is one-to-many, so a member can have many blogs, but member’s detail variables stay the same; ‘name’ and ‘website’.

Any opinion which is better in this case? It’ll be great if you also have the 3rd solution. Thanks before.

  • 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-06-09T01:12:26+00:00Added an answer on June 9, 2026 at 1:12 am

    I think it is fine to keep the member details separate, like a forum signature. That way when a member updates their details all the posts will show their current information without your application having to update duplicate data in every previous post.

    From your description it sounds like you may only be displaying this on blog posts the users create, rather than on every comment they make on a page.

    If you are worried about the performance cost of an extra query per user, you could always cache that user data (or the generated page output) instead of relying on fetching all the blog info in a single DB query. I would see how the application performs in actual usage before trying to optimize for a use case that may not be a problem.

    Another approach would be to only show the extra user details as an Ajax hover (similar to how SO shows more information for an established user.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am sure that this must be a pretty common question but after scouring
I thought this would be a pretty common question to look for in Google
This is a pretty common question, but I could not find this part: Say
I'm pretty sure that this is the right site for this question, but feel
I'm pretty sure that this question already has been answered somewhere. It just seems
I have a question which I think should be pretty common but I can't
I bet this is a pretty common question, which I think can't be solved,
I know this is a pretty common error, usually having to do with the
this pretty much is the thing. When in tinymce I press anything that is
I have written something like this pretty easily in C# ( string GetUrl(new {

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.