创建索引:
如给wechat库的article表中的crawlingrate字段创建降序索引
use wechat
db.article.ensureIndex({crawlingrate:-1})
如果表中已经有大量数据创建索引会很慢,可以加入backgroud:true在后台运行。
db.article.ensureIndex({crawlingrate:-1},{backgroud:true})
查看索引article表有哪些索引
db.article.getIndexes()
删除索引:
如给wechat库的article表中的crawlingrate字段创建降序索引
use wechat
db.article.ensureIndex({crawlingrate:-1})
如果表中已经有大量数据创建索引会很慢,可以加入backgroud:true在后台运行。
db.article.ensureIndex({crawlingrate:-1},{backgroud:true})
查看索引article表有哪些索引
db.article.getIndexes()
删除索引:
db.article.dropIndexes() //删除article所有索引
db.article.dropIndex({crawlingrate:-1}) //删除crawlingrate字段的索引