Mongodb

来源:互联网 发布:mysql 截断 编辑:程序博客网 时间:2024/05/29 18:51

http://www.mongodb.org/

https://docs.mongodb.org/v3.0/

http://docs.mongodb.org/getting-started/shell/

Why Nosql?
http://www.couchbase.com/nosql-resources/what-is-no-sql
https://www.mongodb.com/nosql-explained

http://wiki.jikexueyuan.com/project/mongodb/

第一天
Install MongoDB and basic operation
http://www.cnblogs.com/huangxincheng/archive/2012/02/18/2356595.html

32bit的mongodb最大只能存放2G的数据,64bit就没有限制。
mongodb中有三元素:数据库,集合,文档,其中“集合”就是对应关系数据库中的“表”,“文档”对应“行”。

启动mongodb:
C:\Program Files\MongoDB\Server\3.0\bin>mongod –dbpath=D:\mongoDB\db01

–httpinterface | nohttpinterface
MongoDB disables the HTTP interface by default.
http://docs.mongodb.org/manual/reference/program/mongod/#cmdoption–httpinterface

mongodb client shell
mongo

第二天
CRUD Details
http://www.cnblogs.com/huangxincheng/archive/2012/02/19/2357846.html

CRUD
insert() | find() |update()| remove()

Query selection operator
https://docs.mongodb.org/v3.0/reference/operator/query/#query-selectors

What are indexs in the db and usage?

Some shell commands:
db.getCollectionNames();
show collections
show dbs
db
use dbname
show tables

第三天
聚合 and 游标
http://www.cnblogs.com/huangxincheng/archive/2012/02/21/2361205.html

db.person.count()
db.person.count({“city”:”sh”})

db.person.distinct(“city”)

db.person.group()
http://blog.csdn.net/h70614959/article/details/7780227
https://docs.mongodb.org/manual/reference/command/group/

mapReduce in mongodb
http://www.mongovue.com/2011/04/05/how-to-perform-mapreduce-operations-in-mongovue-a-step-by-step-guide/
http://www.mongovue.com/2010/11/03/yet-another-mongodb-map-reduce-tutorial/
http://blog.csdn.net/zzq900503/article/details/8510030

What is map reduce?
http://www.csdn.net/article/2013-01-07/2813477-confused-about-mapreduce
http://ayende.com/blog/4435/map-reduce-a-visual-explanation
https://docs.mongodb.org/manual/reference/command/mapReduce/#mapreduce-map-cmd
http://www.open-open.com/lib/view/open1329455491750.html

聚合函数
http://www.infoq.com/cn/articles/implementing-aggregation-functions-in-mongodb

为什么要创建view database?

启动mongodb遇到如下异常:
exception in initAndListen: 12596 old lock file, terminating
解决方法
1.删除data目录中的.lock文件
2.mongod.exe –repair
3.启动mongod就可以了
第四天
索引
http://www.cnblogs.com/huangxincheng/archive/2012/02/29/2372699.html

db.collection.find().explain()
cursor.explain()

db.person.find({“name”:”hxc”+10000}).explain(‘allPlansExecution’)

Collection Scan
这里写图片描述
db.person.ensureIndex({“name”:1})
db.person.find({“name”: “hxc”+10000}).explain(“executionStats”)

这里写图片描述
唯一索引
组合索引

db.person.getIndexes()
db.person.dropIndexes(“name_1”)
索引会降低CUD这三种操作的性能,因为这玩意需要实时维护,所以啥问题都要综合考虑一下。

Mongodb主要内容:

1.Index
https://docs.mongodb.org/v3.0/indexes/

0 0