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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:52:03+00:00 2026-05-26T03:52:03+00:00

In an app that uses MongoDB, when/where is the best place to make database

  • 0

In an app that uses MongoDB, when/where is the best place to make database changes that would be migrations in a relational database?

For example, how should creating indexes or setting shard keys be managed? Where should this code go?

  • 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-26T03:52:03+00:00Added an answer on May 26, 2026 at 3:52 am

    it’s probably best to do this in the shell, conciously!, because you could cause havoc if you accidentally start such a command at the wrong moment and on the wrong instance.

    Most importantly: do this offline on an extra slave instance if you add an index on an existing DB! For large data sets, building an index can take hours, even days!

    see also:

    http://www.mongodb.org/display/DOCS/Indexes

    http://www.javabeat.net/articles/print.php?article_id=353

    http://www.mongodb.org/display/DOCS/Indexing+as+a+Background+Operation

    http://nosql.mypopescu.com/post/1312926692/mongodb-indexes-and-indexing

    If you have a large data set, make sure to read up on the 4square outage last year..!!

    http://www.infoq.com/news/2010/10/4square_mongodb_outage

    http://blog.foursquare.com/2010/10/05/so-that-was-a-bummer/

    http://highscalability.com/blog/2010/10/15/troubles-with-sharding-what-can-we-learn-from-the-foursquare.html


    one of the main reasons for not wanting to put indexing in a script or config file of some sort is that in MongoDB the index operation is blocking(!) — that means MongoDB will stop other operations on the database from proceeding until the indexing is completed. Just imagine an innocent change in the code, requiring a new index to improve performance — and this change is carelessly checked-in and deployed to production … and suddenly your production MongoDB is feezing up for your app-server, because MongoDB is internally adding the new index first before doing anything else… outch! Apparently that has happened to a couple of folks, that’s why they keep reminding people at the MongoDB conferences to be careful to not ‘programmatically’ require indexes.

    New versions of MongoDB allow background indexing — you should always do that e.g. db.yourcollection.ensureIndex(…, {background: true})

    otherwise, not-so-fun stuff happens:

    https://jira.mongodb.org/browse/SERVER-1341

    https://jira.mongodb.org/browse/SERVER-3067

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

Sidebar

Related Questions

I'm creating an app that uses ActionBarSherlock. The app consists of three tabs, and
I have an app that uses SSN's to look up people in a database.
I'm creating an app that uses VBO's for drawing. The app draws line segments
I have a Rails app that uses MySQL, MongoDB, NodeJS (and SocketIO). Right now,
I have a django app that uses MySQL as the database backend. It's been
I'm running a Flask-based web app that uses Mongodb (with Pymongo for use in
I'm coding an app that uses an existing database, that database has some tables
I'm creating an app that uses CloudApp . I am using TestHarness in order
I created a web app that uses a MySQL database, but I have to
I have a Rails app that uses MongoDb on the back. I have these

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.