MongoDB tip: Index Consideration/Tips/Limitations

MongoDB Index Consideration and Tips

Insert, delete, update on a collection will update the indexes per transaction.
  • Index improved read performance for queries that are supported by the index.
  • Index will be slower where there are indexes that MongoDB must also update.
  • The speed of updates may be improved because MongoDB will not need to do a collection scan to find target documents.

Index is modified any time when a document:
  • is inserted (applies to all indexes)
  • is deleted (applies to all indexes)
  • is updated in such a way that its indexed field changes


Index limitations:
  • 64 indexes per collection
  • Should never create as many indexes anywhere close to the upper bound
  • Write performance will degrade to unusable at somewhere between 20-30


Index options:
  • Sparse
    - sparse index will skip any document that doesn't contain the field specified
    - syntax: db.<collection>.createIndex( {field_name : 1}, {sparse : true})
  • Unique
    - unique index will prohibit any document with duplicate value in the key selected for the index
    - syntax: db.<collection>.createIndex( {field_name : 1}, {unique : true})
  • Background
    - building index in the background is a non blocking operation whereas the default foreground option is a blocking operation
    - it takes longer to build, takes up more space initially, with less impact, than an index built in the foreground



Comments

Popular posts from this blog

MongoDB Ops Manager Basic Installation and Configuration

Oracle Goldengate Extract, Pump, and Replicat

Oracle Goldengate Extract and Replicat within same DB from one schema to another plus some issues and fixes