mongodb console常用命令
Index
查询所有index
db.system.indexes.find()
查询指定表index
db.activities.getIndexes()
删除指定index
db.activities.dropIndex({created_at:-1})
删除指定数据表所有index
db.activities.dropIndexes()
创建index
db.activities.ensureIndex({created_at:-1})
创建multi-key index
db.activities.ensureIndex({"receivers.id":1,created_at:-1})
参考
http://www.mongodb.org/display/DOCS/Indexes
Profile
获取/设置当前profile设置
> db.setProfilingLevel(2); {"was" : 0 , "slowms" : 100, "ok" : 1} // "was" is the old setting > db.getProfilingLevel() 2
> db.setProfilingLevel(1,20) // log slow operations, slow threshold=20ms > db.getProfilingStatus() // new shell helper method as of v1.7+ { "was" : 1, "slowms" : 20 }
查询profile内容
db.system.profile.find().sort({ts:-1}).limit(5)
参考
http://www.mongodb.org/display/DOCS/Database+Profiler
posted on 2012-04-25 09:59 sleepingfire 阅读(351) 评论(0) 编辑 收藏 举报