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 958723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:54:44+00:00 2026-05-16T00:54:44+00:00

Let me explain my problem, and hopefully someone can offer some good advice. I

  • 0

Let me explain my problem, and hopefully someone can offer some good advice.

I am currently working on a web-app that stores information and meta-data for a large amount of applications. For each application there could be anywhere from 10 to 100’s of comments that are tied to the application and an application version id. I am using MongoDB because of a need for easy future scalability and speed. I have read that comments should be embedded in a collection for read performance reasons, but I’m not sure that this works in my case. I read on another post:

In general, if you need to work with a given data set on its own, make it a collection.

By: @kb

In my case however I don’t need to work on the collection by themselves. Let me explain further. I will have a table of apps (that can be filtered) and will dynamically load entries as you scroll, or filter, through the list of apps. If I embed the comments within the application collection, I am sending ALL the comments when I dynamically load the application entry into the table. However, I would like to do “lazy loading” in that I only want to load the comments when the user requests to see them (by clicking on the entry in the table).

As an example, my table might look like the following

| app name | version | rating | etc. | view comments |
------------------------------------------------------
| app1     | v.1.0   | 4 star | etc. | click me!     |
| app2     | v.2.4.5 | 3 star | etc. | click me!     |
| ...

My question is what would be more efficient? Are reads fast enough on MongoDB that it really doesn’t matter that I am pulling all the comments with each application? If a user did not filter any of the applications and scrolled all the way to the bottom, they might load somewhere between 125k to 250k entries/applications.

  • 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-16T00:54:44+00:00Added an answer on May 16, 2026 at 12:54 am

    I would suggest thinking more specifically about your query – you specify which parts of an object you’d like to return. This should allow you to avoid the overhead of getting a bunch of embedded comments when you’re only interested in displaying some specific bits of information about the application.

    You can do something like: db.collection.find({ appName : 'Foo'}, {comments : 0 }); to retrieve the application object with appName Foo, but specifically exclude the comments object (more likely array of objects) embedded within it.

    From the MongoDB docs

    Retrieving a Subset of Fields
    By default on a find operation, the entire document/object is returned. However we may also request that only certain fields are returned. Note that the _id field is always returned automatically.

    // select z from things where x=3
    db.things.find( { x : 3 }, { z : 1 } );
    

    You can also remove specific fields that you know will be large:

    // get all posts about mongodb without comments
    db.posts.find( { tags : 'mongodb' }, { comments : 0 } );
    

    EDIT
    Also remember the limit(n) function to retrieve only n apps at a time. For instance, getting n=50 apps without their comments would be:

    db.collection.find({}, {comments : 0 }).limit(50);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let me explain the problem: Various pages of my web application contain jQuery UI
I have some problem with generics, let me explain. I have a class which
I'm new to WPF and data binding so hopefully I can explain the problem
I got some problem with reference assignment in java. Let me explain: in my
let me try to explain my problem. I'm currently trying to develop a small
It might sound unnecessary, but let me explain my problem first. Probably then it
I'm struggling with add_custom_command. Let me explain the problem in detail. I've these set
I have a problem with Facebook. Let me explain what I'm trying to do.
Let me explain. Suppose I want to teach Python to someone who only speaks
First let me explain how I currently handle validation, say, for an IPv4 address:

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.