`
sunxboy
  • 浏览: 2829408 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

Compound indexes support in MongoDB

 
阅读更多

Compound indexes support queries on any prefix of the index fields. Index prefixes are the beginning subset of indexed fields. For example, given the index { a: 1, b: 1, c: 1 }, both { a: 1 } and { a: 1, b: 1 }are prefixes of the index.

 

Given the following index:

{ "item": 1, "location": 1, "stock": 1 }

MongoDB can use this index to support queries that include:

  • the item field,
  • the item field and the location field,
  • the item field and the location field and the stock field, or
  • only the item and stock fields; however, this index would be less efficient than an index on onlyitem and stock.

MongoDB cannot use this index to support queries that include:

  • only the location field,
  • only the stock field, or
  • only the location and stock fields.
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics