博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【MongoDB】The basic operation of Index in MongoDB
阅读量:6192 次
发布时间:2019-06-21

本文共 807 字,大约阅读时间需要 2 分钟。

In the past four blogs, we attached importance to the index, including description and comparison with usage of index. Now in this blog, we will mainly focus on the basic operation of index. such query, remove ,repair and so on. 

1. View Index

getIndexes could view all the indexes in the collections.

2. Delete index

 delete all the indexes: db.test.dropIndexes()
 
delete one index:  db.test.dropIndex({name:1})
use the command to delete index:
db.runCommand({dropIndexes:"test",index:{name:1}})

3. rebuild index

db.test.reIndex() is equalant to db.runCommand({reIndex:'test'})
Attention:This operation need to add the lock into the document, so if the collection was filled with a large number of data, this operation would take much time. 
if using repair to fix database, the database will rebuild the index.
你可能感兴趣的文章
ACM小感
查看>>
raid5阵列两块硬盘出现硬件故障怎么恢复数据
查看>>
你所不知道的国内原型图工具mockplus
查看>>
jQuery ajax - getJSON() 方法
查看>>
有谁了解接口虚拟化?威睿接口虚拟化外有哪些品牌?
查看>>
highcharts 小实例 很适合初学者
查看>>
改进spring boot添加监控
查看>>
VisualStudio 2010 UI完全自动化测试实践
查看>>
openflow控制器POX使用指南
查看>>
mysql、systemd、ftp总结
查看>>
Leetcode PHP题解--D63 917. Reverse Only Letters
查看>>
我的友情链接
查看>>
android NDK安装
查看>>
如何将普通无线路由器设置为无线AP
查看>>
实战java虚拟机,一图就懂
查看>>
Observer观察者模式
查看>>
docker 配置国内镜像
查看>>
RSA 050-SEPROSIEM-01试题
查看>>
python自定义异常
查看>>
iOSTabBar图片大小问题
查看>>