标签:执行 under xpl 查看 nbsp .com 注意 通过 drop
索引:
#查看执行计划
db.stu.find().explain();
#创建索引(无此列的记录也会创建索引)
db.bar.ensureIndex({content: 1})
#查看索引
db.bar.getIndexes()
#删除索引
db.bar.dropIndex({content: 1})
#创建多列索引
db.bar.ensureIndex({content: 1, title: -1})
#查询子文档
db.shop.find({‘spc.area‘:‘taiwan‘});
#子文档加索引
db.shop.ensureIndex({‘spc.area‘: 1})
#创建唯一索引
db.bar.ensureIndex({content: 1},{unique: true})
#创建稀疏索引(有列创建,无列忽略)
db.bar.ensureIndex({content: 1},{sparse: true})
注意: 在查询时,普通索引可以通过{content: null}查到,稀疏索引查不到。
#创建hash索引
db.bar.ensureIndex({content: ‘hashed‘})
#重建索引
db.bar.reIndex()
标签:执行 under xpl 查看 nbsp .com 注意 通过 drop
原文地址:http://www.cnblogs.com/AK47Sonic/p/7355837.html