Get document size in Cosmos DB

三世轮回 提交于 2019-12-12 13:30:28

问题


How can I get or figure out the size of a document stored in Cosmos DB?

Is this something already stored within document?


回答1:


If you get (or query) a document, you can then look at the headers that come back, specifically x-ms-resource-usage, which will contain a documentsSize attribute (representing a document's size in kb).

In node/javascript, you'd make a call that looks something like:

client.readDocument(docLink, function (err, doc, headers) {
  ...
})

You'd want to look at headers['x-ms-resource-usage'].




回答2:


Per my experience, all the resources created in azure cosmosdb will automatically generate the following attributes:

_rid

_etag

_ts

_self

id

You could find the meaning of these attributes from here.

In addition , the index strategy also takes up space in your cosmos db.

I search the REST API for Azure Cosmos DB but didn't find the method get the document size directly.

However, the query in cosmosdb consumes RU and RU is related to document size. You could refer to the list mentioned in this article.

Please check the RU when you search documents on portal.

You could also refer to this thread,maybe it has some implications for you.

Hope it helps you.



来源:https://stackoverflow.com/questions/46822854/get-document-size-in-cosmos-db

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!