cosmosdb sql api vs mongodb api用于我的方案. [英] cosmosdb sql api vs mongodb api which one to use for my scenario.

查看:169
本文介绍了cosmosdb sql api vs mongodb api用于我的方案.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为聊天"的文件

I have a document called "chat"

 "Chat": [
        {
          "User": {},
          "Message": "i have a question",
          "Time": "06:55 PM"
        },
        {
          "User": {},
          "Message": "will you be able to ",
          "Time": "06:25 PM"
        },
        {
          "User": {},
          "Message": "ok i will do that",
          "Time": "07:01 PM"
        }

每次收到新的聊天消息时,我都应该可以简单地附加到此数组中.

every time a new chat message arrives i should be able to simple append to this array.

mongodb API聚合管道(预览版)允许我使用诸如$ push $ addToSet之类的内容

mongodb API aggregation pipeline (preview) allows me to use things like $push $addToSet for that

如果我使用sql api,则每次修改它都必须提取整个文档,并每次都要创建一个新文档.

if i use sql api i will have to pull the entire document every time modify it and create a new document every time.

其他注意事项: 该阵列可以快速增长. 该聊天"文档也可能嵌套在其他文档中.

Other Considerations : This array can grow rapidly. This "chat" document might also be nested into other document as well.

我的问题 这是否意味着mongodb API更适合此情况,并且sql api在这种情况下会对性能产生影响?

推荐答案

这是否意味着mongodb API更适合于此和sql API 在这种情况下会对性能产生影响吗?

Does this means that mongodb API is better suited for this and sql api will have a performance hit for this scenario ?

很难说哪个数据库是最佳选择.

It's hard to say which database is the best choice.

是的,如 doc ,Cosmos Mongo API支持更高效的$push$addToSet.但是,实际上,Cosmos Mongo API仅支持MongoDB功能的子集,并将请求转换为Cosmos sql等效项.因此,也许Cosmos Mongo API具有一些不同的行为和结果.但是有责任在Cosmos Mongo API上改进他们对MongoDB的仿真.

Yes,as found in the doc, Cosmos Mongo API supports $push and $addToSet which is more efficient. However,in fact, Cosmos Mongo API just supports a subset of the MongoDB features and translates requests into the Cosmos sql equivalent. So, maybe Cosmos Mongo API has some different behaviours and results. But the onus is on Cosmos Mongo API to improve their emulation of MongoDB.

当涉及Cosmos Sql Api时,目前尚不支持部分更新,但是它正在上路.您可以提交反馈此处.当前,您需要更新整个文档.当然,您可以使用程序执行此操作以释放客户端的压力.

When it comes to Cosmos Sql Api, partial update is not supported so far but it is hitting the road. You could commit feedback here. Currently, you need to update the entire document. Surely, you could use stored procedure to do this job to release pressure of your client side.

我接下来要说的,最重要的是@David提到的限制.文档大小在sql api中有2MB的限制,在mongo api中有4MB的限制: cosmosdb项目的大小限制是多少?.由于您的聊天数据在增长,因此您需要考虑将其拆分.然后给文档一个分区键,例如"type": "chatdata"对其进行分类.

The next thing I want to say, which is the most important, is the limitation mentioned by @David. The document size has 2MB limitation in sql api and 4MB in mongo api:What is the size limit of a cosmosdb item?. Since your chat data is growing, you need to consider to split them. Then give the documents a partition key such as "type": "chatdata" to classify them.

这篇关于cosmosdb sql api vs mongodb api用于我的方案.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆