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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:55:14+00:00 2026-06-05T04:55:14+00:00

I am launching a data storage service for my application. MongoDB is running as

  • 0

I am launching a data storage service for my application. MongoDB
is running as the storage mechanism, and I have created 2 shards to
start.

The application will be storing event data, and all data will be
structured as follows:

{ 
  _id: '4fa2f7e25626cd1374000002', 
  created_at: '2012-05-03T21:25:54 00:00', 
  name: 'client_session_connect', 
  session_remote_id: '74ACF9AA-9E09-11E1-8C9E-8462380DA5E6', 
  zone_id: '74ACF9AA-9E09-11E1-8C9E-1231380DA5E6',
  additional: {
    some_other_key: 'value'
  }
} 

Events will have a variety of names, and any new event can be created
at any time with a new event name. There will be plenty of events in
the system with the same name. _id, created_at, and name will be part
of every event, but no other values are guaranteed.

Based on what I have read (here, and here), it seems that the best sharding key would
be { name: 1, created_at: 1 }. Would I be correct in this
interpretation?

  • 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-05T04:55:15+00:00Added an answer on June 5, 2026 at 4:55 am

    From what you’ve stated, it seems like that would be a good shard key, with a few caveats:

    -shard keys are immutable, so if you ever need to change the “name” field of a document, you’ll need to delete and reinsert it (probably this isn’t an issue for you, unless you intend to change names often).

    -If you write a lot of documents with the same “name” in quick succession, all these writes will go to the same chunk, since “created_at” is presumably an increasing field. Eventually the chunk will be split into multiple chunks and balanced off the receiving machine, so this is only a problem if you expect to receive a huge volume of writes of docs with same “name.”

    -If the “name”s are not uniformly distributed, you could hash the name and store the result in a new field of your document, then make the shard key {hashedName : 1, created_at : 1}. This might give a more even load distribution, reducing the amount of balancing later. It does add a little complexity to your documents, though.

    Assuming you’re aware of these things, {name: 1, created_at: 1} may very well be the best shard key for you.

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

Sidebar

Related Questions

I have created WCF Data service and I hosted in visual studio ASP.net development
While launching the application in my iPhone, I need to download the data from
I have an application where I am launching a new Activity, and need to
I am in a Windows Desktop application and I have a data stream and
Upon launching my application, a few web service calls are made to check for
I have a Clickonce application that is launched from the start menu (local). I
I have a launching Activity A1 which has a start button which starts a
I have trouble launching Glassfish v3 on Mac In Windows, after installation of Glassfish
I have an app launching an executable which is in the same folder as
I noticed that the launching of Java applets using deployJava.js seems to have stopped

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.