dan_0
dan_0

Reputation: 609

Mongoid Index Creation in Production

I recently realized that my Indexes which I set up in my models weren't created in production automatically. I know that I can use a rake task for that:

rake db:mongoid:create_indexes RAILS_ENV=production

But I have now a lot of Data in my DB and expect that the index creation takes some time in which the MongoDB is locked for other requests.

Does anybody know if its locked or running as background process until completion?

Have I overlooked something?

Upvotes: 3

Views: 635

Answers (1)

felix
felix

Reputation: 9285

you can build the index in the background so it won't affect your queries like this:

db.collection.createIndex( { field: 1}, {background: true} )

for more details see index build operations

Upvotes: 3

Related Questions