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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:25:26+00:00 2026-05-20T10:25:26+00:00

Coming from an RDBMS background, I was always under the impression Try as hard

  • 0

Coming from an RDBMS background, I was always under the impression “Try as hard as you can to use one query, assuming it’s efficient,” meaning that it’s costly for every request you make to the database. When it comes to MongoDB, it seems like this might not be possible because you can’t join tables.

I understand that it’s not supposed to be relational, but they’re also pushing it for purposes like blogs, forums, and things I’d find an RDBMS easier to approach with.

There are some hang ups I’ve had trying to understand the efficiency of MongoDB or NoSQL in general. If I wanted to get all “posts” related to certain users (as if they were grouped)… using MySQL I’d probably do some joins and get it with that.

In MongoDB, assuming I need the collections separate, would it be efficient to use a large $in: [‘user1’, ‘user2’, ‘user3’, ‘user4’, …] ?

Does that method get slow after a while? If I include 1000 users?
And if I needed to get that list of posts related to users X,Y,Z, would it be efficient and/or fast using MongoDB to do:

  • Get users array
  • Get Posts IN users array

2 queries for one request. Is that bad practice in NoSQL?

  • 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-20T10:25:26+00:00Added an answer on May 20, 2026 at 10:25 am

    To answer the Q about $in….

    I did some performance tests with the following scenario:

    ~24 million docs in a collection
    Lookup 1 million of those documents based on a key (indexed)
    Using CSharp driver from .NET

    Results:
    Querying 1 at a time, single threaded : 109s
    Querying 1 at a time, multi threaded : 48s
    Querying 100K at a time using $in, single threaded=20s
    Querying 100K at a time using $in, multi threaded=9s

    So noticeably better performance using a large $in (restricted to max query size).

    Update:
    Following on from comments below about how $in performs with different chunk sizes (queries multi-threaded):

    Querying 10 at a time (100000 batches) = 8.8s
    Querying 100 at a time (10000 batches) = 4.32s
    Querying 1000 at a time (1000 batches) = 4.31s
    Querying 10000 at a time (100 batches) = 8.4s
    Querying 100000 at a time (10 batches) = 9s (per original results above)

    So there does look to be a sweet-spot for how many values to batch up in to an $in clause vs. the number of round trips

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

Sidebar

Related Questions

Coming from a .NET background I'm use to reusing string variables for storage, so
Coming from a perl background, I have always defined a 2D array using int[][]
Coming from a java background, one of the things I am used to is
Coming from a background in Django, I often use template inheritance, where multiple templates
Coming from a non-SQL background, I've been having a hard time absorbing SQLite3 for
Coming from a C and C++ background, I found judicious use of typedef to
Coming from a PHP background, I'm used to writing small functions that return a
Coming from a C# Background I never used any pointers. I'm creating a vector
Coming from a C++ background, I am finding cloning of objects in C# a
Coming from C++ it is hard grained into my mind that everytime I call

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.