mongodb怎么查看索引
MongoDB提供了查看索引信息的方法:getIndexes()方法可以用来查看集合的所有索引,totalIndexSize()查看集合索引的总大小,db.system.indexes.find()查看数据库中所有索引信息。
1、查看集合中的索引getIndexes()
db.COLLECTION_NAME.getIndexes()
如,查看集合sites中的索引:
>db.sites.getIndexes() [ { "v":1, "key":{ "_id":1 }, "name":"_id_", "ns":"newDB.sites" }, { "v":1, "key":{ "name":1, "domain":-1 }, "name":"name_1_domain_-1", "ns":"newDB.sites" } ]
2、查看集合中的索引大小totalIndexSize()
db.COLLECTION_NAME.totalIndexSize()
如,查看集合sites索引大小:
>db.sites.totalIndexSize() 16352
3、查看数据库中所有索引db.system.indexes.find()
db.system.indexes.find()
如,当前数据库的所有索引:
>db.system.indexes.find()
本网站文章仅供交流学习 ,不作为商用, 版权归属原作者,部分文章推送时未能及时与原作者取得联系,若来源标注错误或侵犯到您的权益烦请告知,我们将立即删除.