From this blog, we start to talk about the index in mongo Database, which is similar to the traditional database. Generally speaking, if the index need to be created in the traditional database, so does MongoDB.  In MongoDB
,the field '_id ' has been set index by default and this index is so special that it cannot be deleted except for Capped Collections.

Before studying the index, now we create 10000 test records as follows.

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc3hiMDg0MTkwMTExNg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">

1 Create index

In mongodb, using the function ensureIndex() to create tne index, for example:

db.test.ensureIndex({name : 1}) means to create index for name

2. Use index

generally speaking, there is five way to create index based on  the practice condition.

2.1 Common Index

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc3hiMDg0MTkwMTExNg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">

query the result before creating index and after.

Some explanation of result field:

Cursor: value [BasicCursor or BtreeCursor], the later explain this query has used index.

nscanned: the number of index of having scan.

n : return the number of document, namely return the line

millis: the total time of finishing this query, unit millinus seconds.

indexBounds: if not null, it will describe the index item,

【MongoDB】The description of index(一)的更多相关文章

  1. mongodb 中的Multikey Index Bounds解释$elemMatch

    首先说一下 $elemMatch的用法: { _id: 1, results: [ 82, 85, 88 ] } { _id: 2, results: [ 75, 88, 89 ] } $elemMa ...

  2. 【MonogDB】The description of index(二) Embedded and document Index

    In this blog, we will talk about another the index which was called "The embedded ". First ...

  3. MongoDB - basic

    mongoDB basic from:http://www.tutorialspoint.com/mongodb prject:https://github.com/chenxing12/l4mong ...

  4. MongoDB 知识要点一览

    1.启动mongoDb数据库: 进入mongoDB的安装目录,执行如下命令 C:\Program Files\MongoDB\Server\3.0\bin>mongod.exe --dbpath ...

  5. MongoDB.WebIDE:升级版的Mongodb管理工具

    很早以前收藏了一片文章:<强大的MongoDB数据库管理工具>.最近刚好要做一些MongoDB方面的工作,于是翻出来温习了一下,用起来也确实挺方便.不过在使用过程中出现了一些个问题,加上更 ...

  6. Mongodb 和 普通数据库 各种属性 和语句 的对应

    SQL to MongoDB Mapping Chart In addition to the charts that follow, you might want to consider the F ...

  7. MongoDB高级操作

    参考MongoDB菜鸟教程 一.$type操作符 MongoDB 中可以使用的类型如下表所示: 类型 数字 备注 Double 1   String 2   Object 3   Array 4   ...

  8. MongoDB快速入门

    http://www.yiibai.com/mongodb/mongodb_quick_guide.html 创建数据库 MongoDB use DATABASE_NAME 用于创建数据库.该命令如果 ...

  9. node.js+mongodb 爬虫

    demo截图: 本demo爬瓜子二手车北京区的数据 (注:需要略懂 node.js / mongodb 不懂也没关系 因为我也不懂啊~~~) 之所以选择爬瓜子二手车网站有两点: 一.网站无需登录,少做 ...

随机推荐

  1. js和循环依赖

    kmdjs和循环依赖 循环依赖是非常必要的,有的程序写着写着就循环依赖了,可以提取出一个对象来共同依赖解决循环依赖,但是有时会破坏程序的逻辑自封闭和高内聚.所以没解决好循环依赖的模块化库.框架.编译器 ...

  2. Eclipse相关集锦第二季

    Eclipse相关的问题第二季开始了,这些问题都是我平时遇到的,然后记录下来备忘,帮助到别人最好不过了. 1.Unable to execute dex: GC overhead limit exce ...

  3. 3.跟我学solr---使用solrj加入索引

    上一章讲了怎么使用solr admin向solrserver加入索引,Solr 是一个独立的企业级搜索应用server.它对外提供类似于 Web-service 的 API 接口. 用户能够通过 ht ...

  4. unix命令: ifconfig

    ifconfig 命令被用来: 1.为一个网卡分配一个IP地址 2.设置本地环路界面 3.分配一个子网掩码(可选) HP-UX: # /usr/sbin/ifconfig lan0 lan0: fla ...

  5. Linux主机上发布java web应用

    1.链接远程主机命令 ssh user@hostname 如: shh root@192.168.1.1 2.查看主机操作系统版本 uname -a 3.linux系统安装mysql a)检查是否安装 ...

  6. Javascript 进阶 封装

    js中处处是对象,面向对象的第一步当然就是封装了,由于Js中没有类的概念,所以封装起来也比较麻烦,下面介绍两种js的封装. 1.使用约定优先的原则,将所有的私有变量以_开头 <script ty ...

  7. NX-bridge,可以实现无线XBee控制的Arduino板

    ”今天Elecfreaks Studio给你介绍一个新的.很实用的朋友:带有一些奇幻色彩的神秘设备.它是什么呢?它可以完成什么功能呢?它对我们的生活有哪些促进呢?非常感兴趣吧?别着急,我们这就给您详细 ...

  8. MSSQL - 存储过程OutPut返回值

    1.存储过程中不使用外部参数. 存储过程: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ========================== ...

  9. JSP的学习(8)——JSP标签

    JSP标签也称为JSP Action(JSP动作)元素,用于在JSP页面中封装Java代码,这样使得在JSP页面中避免直接编写Java代码,让JSP真正成为MVC模式中的作为视图作用. 几个JSP常用 ...

  10. Delphi的DLL里如何实现定时器功能?

    一,首先引入“mmsystem”单元. 二,启动定时器: var MMTimerID: Integer; // 定时器ID MMTimerID := timeSetEvent(1000, 0, @Ti ...