Comparing Mongo DB and Couch DB

http://www.mongodb.org/display/DOCS/Comparing+Mongo+DB+and+Couch+DB, 英文

http://www.searchdatabase.com.cn/showcontent_46595.htm, 中文

 

最根本的不同是, 应用场景的不同, 是对CAP的取舍的不同

MongoDB选择牺牲可用性来保证一致性和原子性, 而couchDB却是选择放弃一致性而保持高可用性, 所以CouchDB更像KV,nosql, 而MongoDB太象关系型数据库

 

We are getting a lot of questions "how are mongo db and couch different?"  It's a good question: both are document-oriented databases with schemaless JSON-style object data storage.  Both products have their place -- we are big believers that databases are specializing and "one size fits all" no longer applies.

We are not CouchDB gurus so please let us know in the forums if we have something wrong.

 

MVCC

One big difference is that CouchDB is MVCC  based, and MongoDB is more of a traditional update-in-place store.  
MVCC is very good for certain classes of problems:

    • problems which need intense versioning;
    • problems with offline databases that resync later;
    • problems where you want a large amount of master-master replication happening.

Along with MVCC comes some work too:

    • first, the database must be compacted periodically, if there are many updates. 
    • Second, when conflicts occur on transactions, they must be handled by the programmer manually (unless the db also does conventional locking -- although then master-master replication is likely lost).

MongoDB updates an object in-place when possible.  Problems requiring high update rates of objects are a great fit; compaction is not necessary. Mongo's replication works great but, without the MVCC model, it is more oriented towards master/slave and auto failover configurations than to complex master-master setups.  With MongoDB you should see high write performance, especially for updates.

这个应该是最大的区别, MongoDB采用和传统DB类似的策略, update in-place, master/slave, auto failover. MongoDB的特点就是效率高, 尤其是update

而CouchDB就采用比较少见的, append-only方式, 可以支持, MVCC, master/master, 支持offline操作.

 

Horizontal Scalability

One fundamental difference is that a number of Couch users use replication as a way to scale

With Mongo, we tend to think of replication as a way to gain reliability/failover rather than scalability.  Mongo uses (auto) sharding as our path to scalabity (sharding is GA as of 1.6).  In this sense MongoDB is more like Google BigTable.  (We hear that Couch might one day add partitioning too.)

这个也是CouchDB的一大弱点, 我不认为replication能算水平扩展的方法, 如果不支持partition的话...

 

Query Expression

Couch uses a clever index building scheme to generate indexes which support particular queries.  There is an elegance to the approach, although one must predeclare these structures for each query one wants to execute.  One can think of them as materialized views.

Mongo uses traditional dynamic queries.  As with, say, MySQL, we can do queries where an index does not exist, or where an index is helpful but only partially so.  Mongo includes a query optimizer which makes these determinations.  We find this is very nice for inspecting the data administratively, and this method is also good when we don't want an index: such as insert-intensive collections.  When an index corresponds perfectly to the query, the Couch and Mongo approaches are then conceptually similar.  We find expressing queries as JSON-style objects in MongoDB to be quick and painless though.

Update Aug2011: Couch is adding a new query language "UNQL".

MongoDB 与传统的数据库系统类似,支持动态查询,即使在没有建立索引的行上,也能进行任意的查询。而 CouchDB 不同,CouchDB 不支持动态查询,你必须为你的每一个查询模式建立相应的view,并在此view的基础上进行查询.

 

Atomicity

Both MongoDB and CouchDB support concurrent modifications of single documents.  Both forego complex transactions involving large numbers of objects.

都支持原子性修改.

 

Durability

CouchDB is a "crash-only" design where the db can terminate at any time and remain consistent.

Previous versions of MongoDB used a storage engine that would require a repairDatabase() operation when starting up after a hard crash (similar to MySQL's MyISAM). Version 1.7.5 and higher offer durability via journaling; specify the --journalcommand line option

CouchDB是append-only, 再加上两步commit, 可以保证数据的一致性, crash只会导致新数据的丢失, 而不会导致老数据的不一致.

MongoDB就和传统数据库一样, crash必然会导致数据不一致, 需要去repair

 

Map Reduce

Both CouchDB and MongoDB support map/reduce operations.  For CouchDB map/reduce is inherent to the building of all views.  With MongoDB, map/reduce is only for data processing jobs but not for traditional queries.

CouchDB的map/reduce只是用于单节点的view查询, 相当的水

而MongoDB, 用于多shard的数据统计, 相对靠谱一些

 

Javascript

Both CouchDB and MongoDB make use of Javascript.  CouchDB uses Javascript extensively including in the building of views .

MongoDB supports the use of Javascript but more as an adjunct.  In MongoDB, query expressions are typically expressed as JSON-style query objects; however one may also specify a javascript expression as part of the query.  MongoDB also supports running arbitrary javascript functions server-side and uses javascript for map/reduce operations.

简单的说, 就是用在不同的地方

 

REST

Couch uses REST as its interface to the database.  With its focus on performance, MongoDB relies on language-specific database drivers for access to the database over a custom binary protocol.  Of course, one could add a REST interface atop an existing MongoDB driver at any time -- that would be a very nice community project.  Some early stage REST implementations exist for MongoDB.

 

Performance

Philosophically, Mongo is very oriented toward performance, at the expense of features that would impede performance.  We see Mongo DB being useful for many problems where databases have not been used in the past because databases are too "heavy".  Features that give MongoDB good performance are:

  • client driver per language: native socket protocol for client/server interface (not REST)
  • use of memory mapped files for data storage, 所以非常耗内存
  • collection-oriented storage (objects from the same collection are stored contiguously)
  • update-in-place (not MVCC)
  • written in C++

 

Use Cases

It may be helpful to look at some particular problems and consider how we could solve them.

  • if we were building Lotus Notes, we would use Couch as its programmer versioning reconciliation/MVCC model fits perfectly.  Any problem where data is offline for hours then back online would fit this.  In general, if we need severaleventually consistent master-master replica databases, geographically distributed, often offline, we would use Couch.
  • mobile
    • Couch is better as a mobile embedded database on phones, primarily because of its online/offine replication/sync capabilities.
    • we like Mongo server-side; one reason is its geospatial indexes.
  • if we had very high performance requirements we would use Mongo.  For example, web site user profile object storage and caching of data from other sources.
  • for a problem with very high update rates, we would use Mongo as it is good at that because of its "update-in-place" design.  For example see updating real time analytics counters
  • in contrast to the above, couch is better when lots of snapshotting is a requirement because of its MVCC design.

Generally, we find MongoDB to be a very good fit for building web infrastructure.

本文章摘自博客园,原文发布日期:2012-07-02

时间: 2024-09-18 04:34:43

Comparing Mongo DB and Couch DB的相关文章

对于一个偶尔高并发的活动页面(涉及db操作,db为mysql,集群部署),你怎么做

问题描述 对于一个偶尔高并发的活动页面(涉及db操作,db为mysql,集群部署),你怎么做 对于一个偶尔高并发的活动页面(涉及db操作,db为mysql,集群部署),你怎么做 解决方案 高并发的话,可以通过据库集群.库表散列.缓存等技术: 偶尔的话,建议选择mongoDB非关系数据库.你是开发的话我想应该懂mongoDB吧. 对了景安新推出快云mongoDB,你可以去免费公测试试. 解决方案二: 高并发,一般使用负载均衡解决前端访问问题,用进程管理器解决业务逻辑调度问题,db如果是你的业务瓶颈

12c的asm中混搭11g DB和12c DB,报错ora-600

客户的一个数据库,是12c的cluster环境,这个环境中有11g的db和12c的db.当客户准备在一个diskgroup上的数据库拉起来的时候(这个cluster是放多个测试库,是从几十个生产库的disk通过存储级复制的方式,集中起来的.生产库那边一个cluster只有一个database,只有2个diskgroup(DATA和FRA),但是这个测试库集中了多个生产库,所以上面有70个多diskgroup),报错了: ORA-15001:diskgroup "DATA_MIDG" d

如何删除thumbs.db,thumbs.db是什么文件

thumbs.db是什么文件?是不是还有印象,我们外出旅游使用数码相机进行拍照之后存储的文件,都会拷贝到自己的电脑,或者上传到空间,那么是否注意到有个thumbs.db是什么文件. thumbs.db应该是跟图片相关的.thumbs.db其实只是一个图片索引文件,可以加速使用缩略图方式查看图片,它也会随着文件夹的图片的增多而体积增大.那么在有图片的文件夹里这个隐藏的thumbs.db文件可删除吗? 1.thumbs.db如何进行删除 文件删除方法是:利用搜索功能把所有thumbs.db文件找出来

几种常用DB驱动和DB连接串小结_数据库其它

(一) MySQL: (1) JDBC驱动jar包:(http://www.mysql.com) mm.mysql-2.0.2-bin.jar (2) 驱动类classpath:Driver = org.gjt.mm.mysql.Driver (3) 数据库连接URL: url = jdbc:mysql://IP(hostName):3306/DatabaseName. url解释:关键字 jdbc mysql jdbc表示采用方式连接数据库 mysql 表示连接到mysql数据库 (二) Or

NoSQL Databases技术资料整理汇总

0 Reference NoSQL论文 在 Stuttgart Media 大学的 Christof Strauch 历时8个月(2010年6月-2011年2月)完成了一篇150页长的NoSQL相关的论文, 对NoSQL的各个方面做了探讨 http://www.christof-strauch.de/nosqldbs.pdf 分布式系统领域经典论文翻译集 http://duanple.blog.163.com/blog/static/709717672011330101333271/ 2010

关于OLE DB的.NET思考(转自微软)

微软 关于 OLE DB 和 .NET 的思考 你我并不相识.不过,面对一个实实在在的问题"软件到底是什么?",我却没有合适的答案.设想一下这样一个场景:在一个旅游纪念品商店,你正专注于购买一些没用的东西(主要是纪念品),以便让到机场接你的朋友和亲戚感到开心.这时,往往会有人问你:"第一次来吗?出差还是度假?"所以,如果你是在做和软件有关的事,而不是在度假,那你就不得不面对这个现实的问题.那么,软件到底是什么?回答这种关于存在的问题是很困难的,尤其是如果此时你正在闲

利用pear::db联结postgres

pear::DB是除了adodb以外另一个联结数据库的选择,本文以实例介绍介绍如何使用DB联结postgres数据库安装pear本文不作介绍.在pear中,联结数据库的类有如下一些:1>MDB:2>MDB2:因MDB2的作者一直期待PDO进入release状态,所以至今MDB2一直是贝塔版:3>PDO:联结速度应该是最快的,属C模块,但一直未release:听说在PHP5.1中已经作为一个正式模块,用于数据库驱动:4>DB:安装DB:在DEBIAN下安装DB过程很简单:#>s

WinCE BSP中的REG文件和DB文件

1.REG文件 注册表文件,这个和Windows操作系统中使用的注册表文件基本一样,在BSP中主要是Platform.reg,该注册表文件描述了和硬件平台相关的配置,大部分是用来描述驱动的相关信息. 注册标的格式如下: [KEY1] "ValueName1"={Value Type}:{data} "ValueName2"={Value Type}:{data} [KEY2] "ValueName1"={Value Type}:{data} 其中

thinkphp5.x之数据库操作相关解析 Db类

风.fox thinkphp5.x之Collection(集合)解析 php集合 http://blog.csdn.net/fenglailea/article/details/52723586 thinkphp5 数据库 链接 http://blog.csdn.net/fenglailea/article/details/52728899 db函数 本函数没什么好说,直接PASS /** * 实例化数据库类 * @param string $name 操作的数据表名称(不含前缀) * @par