索引的分类
Single Field 单键索引
Compound Index 复合索引
Multikey Index 多键值索引
Geospatial Index 地理索引
Text Indexes 全文索引
Hashed Indexes hash 索引
Unique Indexes 唯一索引
Sparse Indexed 稀疏索引
创建索引
- db.collection.createIndex( , )
1、Single Field 单键索引
- db.customers.createIndex({
- "age": 1
- })
查询,explain() 查询计划
- db.customers.find({
- "age": 45
- }).explain()
stage:IXSCAN 使用了索引
在没有创建索引时,查询 name 字段
- db.customers.find({
- "name": "tomcat1000"
- }).explain()
执行计划的信息
就爱阅读 www.92to.com 网友整理上传, 为您提供最全的知识大全, 期待您的分享,转载请注明出处。