It is impossible to change the index as you described, and if I thought that the result in terms of performance would be similar - how would the database use the half-created / changed index when this operation continued, for example
Instead, I would recommend using a background parameter to create an index on a single node, if this is your configuration, it will take longer, but it will not interfere with normal operation. Once it is completed, you can abandon the old index at your leisure.
However, if you have a set of replicas (recommended), you should be aware that index creation is always (currently) performed in the foreground in the secondary. If you want to avoid loading your minor ones, then you must follow the steps outlined here to accept the member one at a time and build the index needed before reuniting the set:
http://docs.mongodb.org/manual/administration/indexes/#index-building-replica-sets
Update
A secondary index based on secondary features will be available starting with version 2.6 (for more details see release notes ). This will not apply to previous versions, so the above note will be true for versions prior to 2.6.
Finally, as a rule, indexes built in the background will usually be more and less efficient than the built-in indexes in the foreground, so the methodology described above will continue to be used.
Adam comerford
source share