Cosmos DB-5 RU可以写吗? [英] Cosmos DB - 5 RU writes possible?
问题描述
在有关优化操作的文档中在Cosmos DB中,它列出了以下内容:
In the docs on optimizing operations in Cosmos DB, it lists the following:
一次写入的费用,1KB = 5 RU
Cost of one write, 1KB = 5 RU
在什么情况下可以收取5 RU的费用?我已经非常仔细地设计了模型,使模型尽可能地小,并且着眼于效率,但是我写的书从来都不能低于9 RU.
Under what circumstances is a 5 RU charge possible, if it is? I've designed my models very carefully to be as small as possible with an eye toward efficiency, but I've never been able to get under ~9 RU for a write.
例如,一个序列化为334字节JSON的项目报告针对模拟器运行的费用为9.52 RU,我在生产中看到了相似的数字.会话一致性,没有疯狂的索引编制或任何不寻常的配置.
For example, an item serialized to 334 bytes of JSON reports a charge of 9.52 RU run against the emulator, and I've seen similar numbers in production. Session consistency, no crazy indexing or any unusual config.
神话般的5 RU写入是否存在,如何获得一个?应该将更新视为写操作吗?
Does the mythical 5 RU write exist, and how can I get one? Should an update be considered a write?
P.S.如果重要的话,尽管我认为SDK不应该影响RU收费,但我目前正在使用.NET v4 Preview3 SDK.
P.S. If it matters, I'm using the .NET v4 preview3 SDK currently, although I assume SDK shouldn't impact RU charge...
推荐答案
RU将取决于诸如索引,一致性,数据复制之类的因素您应该能够得到
The RUs will dependent on factors like Indexing, Consistency, Data Replication You should be able to get
- 1RU可供读取
- 用于写入的5RU
- 10RUs用于更新(Upsert)
- 5 RU forDelete
具有以下设置
-
查询中始终具有分区键.确保您没有跨分区查询(如果可能,请共享您的JSON结构和分区键的选择
Always have partition key in your Query. Make sure u don't have cross partition query(If possible share your JSON Structure and choice of partition key
索引编制:索引编制消耗大量RU.转到容器"->设定.如果您不需要索引,则应使用以下设置将其禁用
Indexing: Indexing consumes significant RUs. Go to Containers-> Settings. If you don't need indexing u shall disable it with below settings
{"indexingMode":"none",自动":false}
{ "indexingMode": "none", "automatic": false }
数据复制:转到设置"->全局复制数据.禁用多重写入区域
Data Replication: Go to Settings-> Replicate Data globally. Disable MultiWrite region
一致性:转到设置"->DefaultConsistency.将数据一致性设置为最终.
Consistency: Go to Settings -> DefaultConsistency. Set data consistency to eventual.
参考: https://docs.microsoft.com/zh-CN/azure/cosmos-db/request-units#request-unit-considerations
这篇关于Cosmos DB-5 RU可以写吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!