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.

【MongoDB】The basic operation of Index in MongoDB的更多相关文章

  1. 【LeetCode】880. Decoded String at Index 解题报告(Python)

    [LeetCode]880. Decoded String at Index 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博 ...

  2. 【LeetCode】227. Basic Calculator II 解题报告(Python)

    [LeetCode]227. Basic Calculator II 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: h ...

  3. 【LeetCode】227. Basic Calculator

    Problem: Implement a basic calculator to evaluate a simple expression string. The expression string ...

  4. 【CXF】: No binding operation info while invoking unknown method with params unknown.

    CXF发布webservice之后访问报错: org.apache.cxf.interceptor.Fault: No binding operation info while invoking un ...

  5. 【LeetCode】227. Basic Calculator II

    Basic Calculator II Implement a basic calculator to evaluate a simple expression string. The express ...

  6. 【LeetCode】224. Basic Calculator

    Basic Calculator Implement a basic calculator to evaluate a simple expression string. The expression ...

  7. 【error】scripts/basic/fixdep: Syntax error: "(" unexpected

    前言 第一次安装PCIE驱动的时候容易出现各种问题,总结一下下.. 原因分析 一般情况下,直接make的时候会出现问题. scripts/basic/fixdep: : scripts/basic/f ...

  8. 【Leetcode】583. Delete Operation for Two Strings

    583. Delete Operation for Two Strings Given two words word1 and word2, find the minimum number of st ...

  9. 【Nginx】Nginx配置REWRITE隐藏index.php

    只需要在server里面加上 if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; break; }

随机推荐

  1. [源码管理] Microsoft Visual SourceSafe 2005 下载与配置

    一.VSS2005的下载地址是:百度搜索关键字:vss, 二.配置Microsoft Visual SourceSafe 2005的Internet访问 VSS2005发布以后,早就听说可以支持Int ...

  2. js重定向

    在现行的网站应用中URL重定向的应用有很多: 404页面处理.网址改变(t.sina转到weibo.com).多个网站地址(如:http://www.google.com/ .www.g.cn )等: ...

  3. css兼容性的一些问题

    1. 文字本身的大小不兼容.同样是font-size:14px的宋体文字,在不同浏览器下占的空间是不一样的,ie下实际占高16px,下留白3px,ff 下实际占高17px,上留白1px,下留白3px, ...

  4. Wannafly挑战赛25 A 因子 数学

    题面 题意:令 X = n!,给定一大于1的正整数p,求一个k使得 p ^k | X 并且 p ^(k + 1) 不是X的因子,n,,p(1e18>=n>=1e4>=p>=2) ...

  5. JsonResult

    注意:如果有大量的json数据要处理,建议使用ASP .NET Web API框架处理,专门用来处理json数据交换并提供跨平台访问能力的 ConentType设置为application/json ...

  6. Array.of()和Array()区别

    Array.of方法用于将一组值,转换为数组. Array.of(3, 11, 8) // [3,11,8] Array.of(3) // [3] Array.of(3).length // 1 这个 ...

  7. hdu2686/hdu3376 最小费用流最大流 拆点

    虽然题目求的是最大费用,但是我们可以通过转换就变为最小费用.用一个比最大值更的数与每个数的差作为费用值.最后处理回来就i可以了.有些人用直接每个值都乘以-1,这样更简单. 做这题,我对为什么不拆点就会 ...

  8. java是值传递,还是引用传递?

    原文地址:http://blog.csdn.net/zxmzfbdc/article/details/5401960  java到底是值传递,还是引用传递?以前国内的java开发者有过很多争论,由于& ...

  9. 异常及String

    异常时描述错误信息的对象,在编码过程中我们会遇到很多异常 例如: 1.java.lang.ArithmeticException 算数异常.算数运算出现错误时抛出 比如用0做除数 2.java.lan ...

  10. 引用css样式的书写格式

    css的书写格式一共有三种 行内样式:意思是在行内中写样式 例如说<p style="color:red">用行内样式编写我的颜色</p> 只适用于< ...