Indexing in mongoid: when and how often should I run rake db:mongoid:create_indexes?
It's not quite clear from the documentation: when and how often should I run rake db:mongoid:create_indexes
. Let's say I added some inde开发者_如何学编程xes macro to the models already and am never going to add new ones in the future. Does that mean I may run the rake task just once or should I be running it, say, once a day?
You should run the task once.
After the indexes have been created, you don't need to run the command anymore as the indexes already exist and don't need to be added again.
Of course, if you create new indexes, you'll need to run the command to add the new indexes to mongodb.
精彩评论