1

I want to create Index in mongodb , but with the classic method

db.OPC_PLANT_DATA.createIndex( { "ITEM_ID" : 1.0,"ITEM_TIMESTAMP" : -1.0 } )

the db get stucked and it takes lot of time , so if I want to do it in Production it will impcat all the work !!

Someone knows how to do it without having any impact on documents insertion ??

1 Answer 1

1

Mongo Db allowed creation of indices in background. You had to specify background:true option while creating an index.

This was deprecated in version 4.2 of mongo though because they've optimized the index creation process.

Read the relevant documentation chapter

Sign up to request clarification or add additional context in comments.

2 Comments

can you please give me the exactly place os syntaxe where to specify background:true in the query
db.collection.createIndex(<keys_to_create_index>, {'background' : true}) I guess (don't have a working mongo instance to check). Here is a documentation docs.mongodb.com/manual/reference/method/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.