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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:49:39+00:00 2026-05-15T12:49:39+00:00

Background I’m prototyping a conversion from our RDBMS database to MongoDB. While denormalizing, it

  • 0

Background
I’m prototyping a conversion from our RDBMS database to MongoDB. While denormalizing, it seems as if I have two choices, one which leads to many (millions) of smaller documents or one which leads to fewer (hundreds of thousands) large documents.

If I could distill it down to a simple analog, it would be the difference between a collection with fewer Customer documents like this (in Java):

class Customer {
    private String name;
    private Address address;
    // each CreditCard has hundreds of Payment instances
    private Set<CreditCard> creditCards;
}

or a collection with many, many Payment documents like this:

class Payment {
    private Customer customer;
    private CreditCard creditCard;
    private Date payDate;
    private float payAmount;
}

Question
Is MongoDB designed to prefer many, many small documents or fewer large documents? Does the answer mostly depend on what queries I plan on running? (i.e. How many credit cards does customer X have? vs What was the average amount all customers paid last month?)

I’ve looked around a lot but I didn’t stumble into any MongoDB schema best practices that would help me answer my question.

  • 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-15T12:49:40+00:00Added an answer on May 15, 2026 at 12:49 pm

    You’ll definitely need to optimize for the queries you’re doing.

    Here’s my best guess based on your description.

    You’ll probably want to know all Credit Cards for each Customer, so keep an array of those within the Customer Object. You’ll also probably want to have a Customer reference for each Payment. This will keep the Payment document relatively small.

    The Payment object will automatically have its own ID and index. You’ll probably want to add an index on the Customer reference as well.

    This will allow you to quickly search for Payments by Customer without storing the whole customer object every time.

    If you want to answer questions like “What was the average amount all customers paid last month” you’re instead going to want a map / reduce for any sizeable dataset. You’re not getting this response “real-time”. You’ll find that storing a “reference” to Customer is probably good enough for these map-reduces.

    So to answer your question directly: Is MongoDB designed to prefer many, many small documents or fewer large documents?

    MongoDB is designed to find indexed entries very quickly. MongoDB is very good at finding a few needles in a large haystack. MongoDB is not very good at finding most of the needles in the haystack. So build your data around your most common use cases and write map/reduce jobs for the rarer use cases.

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

Sidebar

Related Questions

Background I have a form that PHP generates from my database. The page is
BACKGROUND: Right now, in our company we have a PHP based app to automate
Background We have a Windows .NET application used by our field employees who travel
Background: We're building an application that allows our customers to supply data in a
Background: I would like to dismiss a modalView that I have presented earlier and
Background: Using unix, codeigniter from localhost. I'd like to run a controllers via a
Background: I have a css and a js that is used only by the
Background: Sometimes when editing in vim it is possible to have extra characters in
Background A lot of work has gone into optimizing database design, especially in the
Background I have a ror application which is continuously recording and showing on a

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.