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

本文共 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.
你可能感兴趣的文章
String.trim
查看>>
缓存行 伪共享
查看>>
400 : perceived to be a client error 错误
查看>>
Establishing SSL connection without server's identity verification is not recommended
查看>>
扫描包不存在:pojo类找不到
查看>>
c语言中计算数组长度的方法
查看>>
java 数组定义
查看>>
java中的&和&&的区别
查看>>
Java的位运算符
查看>>
BufferedReader与Scanner的区别
查看>>
java String于常量池中的介绍
查看>>
java Text 错误: 找不到或无法加载主类 Text
查看>>
XShell连接ubantu:给ubantu安装ssh
查看>>
c语言的null和0
查看>>
二进制详解:世界上有10种人,一种懂二进制,一种不懂。
查看>>
c语言一个字符变量存储多个字符
查看>>
java接口中方法的默认访问修饰符为public
查看>>
java多线程之并发synchronized
查看>>
java多线程之并发Lock
查看>>
微信公众平台基础配置
查看>>