Skip to content

Commit 35432c4

Browse files
authored
Merge pull request #2277 from zouwei/main
feat:Amazon Document与MongoDB 的差异
2 parents ee81831 + 504827e commit 35432c4

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

docs/database/mongodb/mongodb-questions-01.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,65 @@ MongoDB 单文档原生支持原子性,也具备事务的特性。当谈论 Mo
274274

275275
WiredTiger 日志也会被压缩,默认使用的也是 Snappy 压缩算法。如果日志记录小于或等于 128 字节,WiredTiger 不会压缩该记录。
276276

277+
## Amazon Document与MongoDB 的差异
278+
279+
Amazon DocumentDB(与 MongoDB 兼容) 是一种快速、可靠、完全托管的数据库服务。Amazon DocumentDB 可在云中轻松设置、操作和扩展与 MongoDB 兼容的数据库。
280+
281+
### `$vectorSearch` 运算符
282+
283+
Amazon DocumentDB 不支持`$vectorSearch`作为独立运营商。相反,我们在`$search`运营商`vectorSearch`内部支持。有关更多信息,请参阅 [向量搜索 Amazon DocumentDB](https://docs.aws.amazon.com/zh_cn/documentdb/latest/developerguide/vector-search.html)
284+
285+
### `OpCountersCommand`
286+
287+
Amazon DocumentDB 的`OpCountersCommand`行为偏离于 MongoDB 的`opcounters.command` 如下:
288+
289+
- MongoDB 的`opcounters.command` 计入除插入、更新和删除之外的所有命令,而 Amazon DocumentDB 的 `OpCountersCommand` 也排除 `find` 命令。
290+
- Amazon DocumentDB 将内部命令(例如`getCloudWatchMetricsV2`)对 `OpCountersCommand` 计入。
291+
292+
### 管理数据库和集合
293+
294+
Amazon DocumentDB 不支持管理或本地数据库,MongoDB `system.*``startup_log` 集合也不支持。
295+
296+
### `cursormaxTimeMS`
297+
298+
在 Amazon DocumentDB 中,`cursor.maxTimeMS` 重置每个请求的计数器。`getMore`因此,如果指定了 3000MS `maxTimeMS`,则该查询耗时 2800MS,而每个后续`getMore`请求耗时 300MS,则游标不会超时。游标仅在单个操作(无论是查询还是单个`getMore`请求)耗时超过指定值时才将超时`maxTimeMS`。此外,检查游标执行时间的扫描器以五 (5) 分钟间隔尺寸运行。
299+
300+
### explain()
301+
302+
Amazon DocumentDB 在利用分布式、容错、自修复的存储系统的专用数据库引擎上模拟 MongoDB 4.0 API。因此,查询计划和`explain()` 的输出在 Amazon DocumentDB 和 MongoDB 之间可能有所不同。希望控制其查询计划的客户可以使用 `$hint` 运算符强制选择首选索引。
303+
304+
### 字段名称限制
305+
306+
Amazon DocumentDB 不支持点“。” 例如,文档字段名称中 `db.foo.insert({‘x.1’:1})`
307+
308+
Amazon DocumentDB 也不支持字段名称中的 $ 前缀。
309+
310+
例如,在 Amazon DocumentDB 或 MongoDB 中尝试以下命令:
311+
312+
```shell
313+
rs0:PRIMARY< db.foo.insert({"a":{"$a":1}})
314+
```
315+
316+
MongoDB 将返回以下内容:
317+
318+
```shell
319+
WriteResult({ "nInserted" : 1 })
320+
```
321+
322+
Amazon DocumentDB 将返回一个错误:
323+
324+
```shell
325+
WriteResult({
326+
"nInserted" : 0,
327+
"writeError" : {
328+
"code" : 2,
329+
"errmsg" : "Document can't have $ prefix field names: $a"
330+
}
331+
})
332+
```
333+
334+
335+
277336
## 参考
278337

279338
- MongoDB 官方文档(主要参考资料,以官方文档为准):<https://www.mongodb.com/docs/manual/>

0 commit comments

Comments
 (0)