问题描述
如果我在cosmos db中编写了一个javascript存储过程,并循环浏览了1000个文档,而每个文档的大小均为1K,是否要花费我1000卢布?
If I write a javascript store procedure in cosmos db and I loop through 1000 document and each doc is 1K size, does it cost me 1000 RU?
推荐答案
RU计算不能像这样(例如,您不能简单地假设1K doc x 1000 = 1000 RU).
RU calculation doesn't work like that (eg you cannot simply assume 1K doc x 1000 = 1000 RU).
确定存储过程成本的最准确方法是检查RU费用,该费用在调用存储过程后的标头中返回.
The most accurate way of determining the cost of your stored procedure is to examine the RU charge, which is returned in the headers following the call to the stored procedure.
标头为x-ms-request-charge
,并通过SDK调用以及原始REST调用中返回的标头公开.
The header is x-ms-request-charge
and is exposed via the returned headers in the SDK calls as well as raw REST calls.
在node/javascript中,您将拨打类似于以下内容的呼叫:
In node/javascript, you'd make a call that looks something like:
client.executeStoredProcedure(sprocLink,params,options, function (err, doc, headers) {
...
})
您想看看headers['x-ms-request-charge']
.
这篇关于如何计算服务器端脚本中使用的Azure Cosmos DB RU的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!