由于mongodb是基于JSON的存储方式,所以你可以随意设计你的数据结构,“Just do whatever you want to do",这是官方的说法,不过究竟嵌套文档的层次有多深这个只有自己去做测试,目前shitou在项目中嵌套已经达到6,7层了,性能仍有不错的表现。
从“Any performance problem can be resolved by changing schema”可以看出mongodb对自己在简单存储模式(没有大量sub-document)下海量数据的查询还是很有信心的,shitou之前做个测试在400w数据查询的时候性能表现的确不错,感兴趣的同学可以看这里(亿级测试)。
shitous-MacBook:mongodb-osx-x86_64-1.4.2 lilei$ pwd
/usr/local/mongodb-osx-x86_64-1.4.2
shitous-MacBook:mongodb-osx-x86_64-1.4.2 lilei$ sudo bin/mongod
Password:
bin/mongod --help for help and startup options
Tue May 25 10:22:33 Mongo DB : starting : pid = 212 port = 27017 dbpath = /data/db/ master = 0 slave = 0 64-bit
Tue May 25 10:22:33 db version v1.4.2, pdfile version 4.5
Tue May 25 10:22:33 git version: 53749fc2d547a3139fcf169d84d58442778ea4b0
Tue May 25 10:22:33 sys info: Darwin erh2.10gen.cc 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_37
Tue May 25 10:22:33 waiting for connections on port 27017
Tue May 25 10:22:33 web admin interface listening on port 28017
Tue May 25 10:22:56 connection accepted from 127.0.0.1:49332 #1
Tue May 25 10:22:57 query admin.$cmd ntoreturn:1 command reslen:298 752ms
这样启动就可以了,默认管理端口为28017, 服务端口为27017
进入console
shitous-MacBook:mongodb-osx-x86_64-1.4.2 lilei$ bin/mongo
MongoDB shell version: 1.4.2
url: test
connecting to: test
type "help" for help
>