AbdelAziz ESSAADI
AbdelAziz ESSAADI

Reputation: 21

Create index in MongoDB

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 ??

Upvotes: 1

Views: 1985

Answers (1)

Mark Bramnik
Mark Bramnik

Reputation: 42481

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

Upvotes: 1

Related Questions