When is preferred to use a standard index instead of a background index in MongoDB?
MongoDB 1.6 allows to define indexes to be run as background operations. Background indexes seems to be a little slower, but doesn't block other write/read operations so they seems to be the best choice wh开发者_StackOverflow社区en you need to create indexes on databases already populated with some data.
However, even with empty collections, background indexes allows you to reindex your collection in the future without worrying about concurrent request.
At first glance, I don't see any real advantage of using legacy indexes over background indexes. However, because MongoDB background indexes are not the default option, I'd like to know if is there any tradeoff I didn't considered.
When is preferred to use a standard index instead of a background index in MongoDB.
Background indexes seems to be a little slower,
I think this is the key trade-off. In some cases, background indexes will be much, much slower. It's easy to imagine a DB with enough writes that the index creation takes hours or days to catch up.
If this is the case, you normally have to find a way to "queue" your writes until you're done. But being able to "lock out" writes during this time frame is a nice feature.
精彩评论