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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:46:03+00:00 2026-06-15T14:46:03+00:00

Can I modify existing index in MongoDB without dropping it ? I don’t see

  • 0

Can I modify existing index in MongoDB without dropping it ? I don’t see anything about it in documentation.

I have an non-unique index on String field. Collection is ~6M documents. It’s replica set.

I know I can delete index and add new one. But it’s problematic due to two reasons:

1) at time while index doesn’t exist some queries will be very very slow.
2) adding new index (in my project) creates very high load on DB which visibly slows down my web-site.

  • 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-15T14:46:04+00:00Added an answer on June 15, 2026 at 2:46 pm

    There is no way to alter an index as you describe, and if there was I think the outcome in terms of performance would be similar – how would the database use the half created/altered index while this operation was going on for example?

    Instead I would recommend using the background option to build the index on a single node, if that is your configuration – it will take longer but will not interfere with your normal operation as much. Once it is finished you can drop the old index at your leisure.

    However, if you have a replica set (recommended) you should be aware that index creation is always (currently) done in the foreground on the secondary. If you want to avoid load on your secondaries, then you should follow the steps outlined here to take a member out one at a time and build the index required before rejoining the set:

    http://docs.mongodb.org/manual/administration/indexes/#index-building-replica-sets

    Update

    Background index builds on secondaries will be possible starting with the 2.6 release (see release notes for details). This is not going to be backported to prior versions, so the above note will be true for versions prior to 2.6.

    Finally, As a general note, indexes built in the background will generally be larger and a less efficient than those built in the foreground, so the methodology above will still have its uses.

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

Sidebar

Related Questions

I have an existing JComboBox object. I can modify many of its properties using
How can I modify my existing JQuery code to loop through a JSON array
Some C functions can modify the string value without that I pass the address
I have a form where users can modify a collection of objects using a
I want to know I can dynamically modify an existing Crystal Report (using C#
Is there a way to modify existing .NET assemblies without resorting to 3rd party
Hi Teradata colleagues! I have to do some modifications in production: 1) Modify existing
I am hoping that someone can modify my existing query and provide me the
How can I modify this existing preg_replace to only allow numbers? function __cleanData($c) {
How can I modify an existing *.gem file? I want to modify a Rakefile

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.