mongodb建立索引&查看索引&删除索引

mongodb建立索引&查看索引&删除索引,第1张

从Robo 3T可视化界面中,去创建mongodb数据表的索引

1.数据表结构:{_id:value,   doc_city:value,    doc_province:value,   content,   judgementId}

2.content字段展开:

3.对content字段里的title/caseType/judgementType建立索引

db.getCollection('chongqing').createIndex({"content.title":1, "content.judgementType":1, "content.caseType":1})

4.让创建索引的过程在后台运行

db.getCollection('chongqing').createIndex({"content.title":1, "content.judgementType":1, "content.caseType":1},{background:true})

5.查询集合索引

db.getCollection('chongqing').getIndexes()

6.查看索引集合大小

db.getCollection('chongqing').totalIndexSize()

7.删除集合所有索引

db.getCollection('chongqing').dropIndexes()

8.删除集合指定索引

db.getCollection('chongqing').dropIndex('索引名')

导致性能下降。MongoDB是一个基于分布式文件存储的数据库,其中该数据库删除记录对索引的影响是导致性能下降,MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/9628872.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-30
下一篇 2023-04-30

发表评论

登录后才能评论

评论列表(0条)

保存