mongodb笔记

最大的BSON文档的大小是16兆,超过这个大小需要使用GrdiFS API
文档需要_id域作为主键,如果没有指定_id域,那么会使用ObjectIds 作为默认值。
对于WiredTiger storage engine readConcern选项允许选择读的隔离级别,可以使用majority,这个级别可以读写入到replica set大部分成员中的数据,不可回滚。
MMAPv1 存储引擎,只能指定local级别
默认情况下mongodb使用local级别,不保证读的数据不会回滚。

level Description
“local”
Default. The query returns the instance’s most recent copy of data. Provides no guarantee that the data has been written to a majority of the replica set members.
“majority”
The query returns the instance’s most recent copy of data confirmed as written to a majority of members in the replica set.

To use a read concern level of “majority”, you must use the WiredTiger storage engine and start the mongod instances with the –enableMajorityReadConcern command line option (or the replication.enableMajorityReadConcern setting if using a configuration file).

Only replica sets using protocol version 1 support “majority” read concern. Replica sets running protocol version 0 do not support “majority” read concern.

To ensure that a single thread can read its own writes, use “majority” read concern and “majority” write concern against the primary of the replica set.

mongodb中一个写操作,如果这个写操作修改了一个记录,那么是原子操作,如果这个写操作修改了几个记录,那么对每个记录来说是原子操作,但是整体上不是一个原子操作,可以使用 isolated isolated does not work with sharded clusters.
一个隔离的写操作不会提供“all-or-nothing”的原子性,不会回滚遇到错误之前的所有的改变。
并发控制,mongodb中使用下面2个方法:
1创建唯一索引
2Another approach is to specify the expected current value of a field in the query predicate for the write operations.
Read uncommitted is the default isolation level and applies to mongod standalone instances as well as to replica sets and sharded clusters.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值