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. Objective-C中的SEL、IMP和Class类型

    1.SEL类型 例子: SEL say;        SEL skin; Objective-C 在编译的时候, 会根据方法的名字(包括参数序列),生成一个用 来区分这个方法的唯一的一个 ID,这个 ...

  2. 如何删除JAVA集合中的元素

    经常我们要删除集合中的某些元素.有些可能会这么写. public void operate(List list){ for (Iterator it = list.iterator(); it.has ...

  3. thinkphp 设置跨域请求

    场景:我的本地网页服务器无法访问本地的接口服务器接口提示一下错误:大致意思是:是一个跨域请求我的没有访问该地址的权限(接口服务器采用的是PHP编写) XMLHttpRequest cannot loa ...

  4. Eclipse和PyDev搭建完美Python开发环境(Windows篇)(转)

      摘要:本文讲解了用Eclipse和PyDev搭建Python的开发环境. 十一长假在家闲着没事儿,准备花点时间学习一下Python. 今儿花了一个下午搭建Python的开发环境,不禁感叹————开 ...

  5. 深入浅出OpenStack云计算平台管理(nova-compute/network)

    一.本课程是怎么样的一门课程(全面介绍)          1.1. 课程的背景           OpenStack是 一个由Rackspace发起.全球开发者共同参与的开源项目,旨在打造易于部署 ...

  6. javascript 学习资料网址一览

    1.http://www.runoob.com/ 2.https://developer.mozilla.org/zh-CN/ 3.http://www.imooc.com/   视频类

  7. Selenium WebDriver TestNg Maven Eclipse java 简单实例

    环境准备 前提条件Eclipse 已经安装过 TestNg ,Maven 插件 新建一个普通的java项目 点击右键 configure->convert to Maven Project 之后 ...

  8. MongoDB学习笔记(二) 通过samus驱动实现基本数据操作

    传统的关系数据库一般由数据库(database).表(table).记录(record)三个层次概念组成,MongoDB是由(database).集合(collection).文档对象(documen ...

  9. MFC的消息反射机制

    1.消息反射解释: 父窗口将子窗口发给它的通知消息,首先反射回子窗口进行处理(即给子窗口一个机会,让子窗口处理此消息),这样通知消息就有机会能被子窗口自身进行处理. 2.MFC中引入消息反射的原因: ...

  10. Mysql 和Oracle rows 区别

    mysql> explain select t1.* from t2 ,t1 where t2.id=t1.id and t2.id<3;\ +----+-------------+--- ...