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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:52:04+00:00 2026-06-10T10:52:04+00:00

I am currently evaluating the efficiency of different databases for a use case. In

  • 0

I am currently evaluating the efficiency of different databases for a use case. In Mongodb, would like to store around 1 million objects with the following structure. Each object will have between 5 and 10 objects in the foo array.

{
   name:"my name",
   foos:[
      {
         foo:"...",
         bar:"..."
      },
      {
         foo:"...",
         bar:"..."
      },
      {
         foo:"...",
         bar:"..."
      }
   ]
}

I often need to search for objects which where the foos collection contains an object with a specific property, e.g.:

// mongo collection
[
   {
      name:'my name',
      foos:[
         {
            foo:'one_foo',
            bar:'a_bar'
         },
         {
            foo:'two_foo',
            bar:'b_bar'
         }
      ]
   },
   {
      name:'another name',
      foos:[
         {
            foo:'another foo',
            bar:'a_bar'
         },
         {
            foo:'just another foo',
            bar:'c_bar'
         }
      ]
   }
]

// search (pseudo code)
{ foos: {$elemMatch: {bar: 'c_bar'}} }
// returns
{
      name:'another name',
      foos:[
         {
            foo:'another foo',
            bar:'a_bar'
         },
         {
            foo:'just another foo',
            bar:'c_bar'
         }
      ]
   }

Can this efficiently be done with mongo and how should the indexes be set?
I don’t want you to evaluate performance for me, just an idea how mongo performs for my use case or how optimization could look like.

  • 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-10T10:52:06+00:00Added an answer on June 10, 2026 at 10:52 am

    MongoDB has documentation explaining how to create indexes on embedded documents, through dot notation:

    Dot Notation (Reaching into Objects)

    > db.blogposts.findOne()
    { title : "My First Post", author: "Jane",
      comments : [{ by: "Abe", text: "First" },
                  { by : "Ada", text : "Good post" } ]
    }
    > db.blogposts.find( { "comments.by" : "Ada" } )
    
    > db.blogposts.ensureIndex( { "comments.by" : 1 } );
    

    As for the performance characteristic… just test it with your dataset.

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

Sidebar

Related Questions

I am currently evaluating Install4J for my company. We have a use case where
We are currently evaluating failover support in different databases. We were earlier using HSQLDB
Am currently evaluating the best RIA technologies to use for building a new e-commerce
I am currently evaluating message queue systems and RabbitMq seems like a good candidate,
I am currently evaluating JMS and I don't get what I could use it
Currently evaluating Dreamweaver CS 5.5. I like much of it - but wondering about
Im currently evaluating different ESB Products (in fact im focuding on mule right now).
I'm currently evaluating GeneXus X, and I'd like to know where I could get
I'm currently evaluating the technologies we want to use for our next project. It
I'm currently evaluating the MSF for CMMI process template under TFS for use on

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.