如何计算 SimpleDB 域的存储大小?

发布于 2024-09-05 07:11:15 字数 759 浏览 0 评论 0原文

官方文档指出:

所有项目 ID 的原始字节大小 (GB) + 每项 45 字节 + 原始字节大小 (GB) 所有属性名称 + 每个属性名称 45 个字节 属性名称 + 原始字节大小 (GB) 所有属性值对 + 45 字节 每个属性值对

属性-值对的原始大小是多少?它正是值的大小吗? (我希望如此,但是为什么它被称为“属性值对”?)或者它是属性名称的大小加上属性值的大小? (在这种情况下,就会有动机为您的属性指定非常短的名称。)

例如,下面的小域的大小是多少?

+---------------------------------------------------------+
| Item Name/ID | "Price" attribute | "Calories" attribute |
|--------------+-------------------+----------------------|
| "apple"      | "0000.43"         | "0046"               |
| "orange"     | "0000.70"         | "0053"               |
+---------------------------------------------------------+

The official documentation states:

Raw byte size (GB) of all item IDs +
45 bytes per item + Raw byte size (GB)
of all attribute names + 45 bytes per
attribute name + Raw byte size (GB) of
all attribute-value pairs + 45 bytes
per attribute-value pair

What is the raw size of an attribute-value pair? Is it precisely the size of the value? (I would expect so, but then why is it worded "attribute-value pair"?) Or is it the size of the attribute name plus the size of the attribute value? (In that case, there would be motivation to give your attributes really short names.)

For example, what is the size of the tiny domain below?

+---------------------------------------------------------+
| Item Name/ID | "Price" attribute | "Calories" attribute |
|--------------+-------------------+----------------------|
| "apple"      | "0000.43"         | "0046"               |
| "orange"     | "0000.70"         | "0053"               |
+---------------------------------------------------------+

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

做个少女永远怀春 2024-09-12 07:11:16

属性名称只计算一次。示例域的大小将按如下方式计算:

  • 项目名称:(5 + 45) + (6 + 45) = 101
  • 属性名称:(5 + 45) + (8 + 45) = 103
  • 属性值:(7 + 45) + (4 + 45) + (7 + 45) + (4 + 45) = 202
  • 总计:406 字节

SimpleDB 论坛上的这个帖子更详细地讨论了计算:
http://developer.amazonwebservices。 com/connect/thread.jspa?threadID=23527&tstart=0&messageID=96906#96906

The attribute name is only counted once. The size of your sample domain would be calculated like this:

  • Item names: (5 + 45) + (6 + 45) = 101
  • Attribute names: (5 + 45) + (8 + 45) = 103
  • Attribute values: (7 + 45) + (4 + 45) + (7 + 45) + (4 + 45) = 202
  • Total: 406 bytes

This thread on the SimpleDB forum discusses the calculation in more detail:
http://developer.amazonwebservices.com/connect/thread.jspa?threadID=23527&tstart=0&messageID=96906#96906

太阳公公是暖光 2024-09-12 07:11:15

每个域有两种不同的存储大小。基本大小仅包括您已存储的基本数据,并由 SimpleDB 服务在强制执行大小配额时使用(每个域 10 GB,来自 Select 的 1 MB 响应)。另一个大小数字仅用于计费目的,还包括幕后用于索引的存储。计算两个存储数量所需的全部 6 个值均可通过 DomainMetadata 操作获得。

计算基本存储

计算基本存储只需要其中三个值:
项目名称大小字节、属性名称大小字节和属性值大小字节。这些值表示唯一项目名称长度、唯一属性名称长度和所有属性值长度的总和。基本存储的公式为:

baseStorage = 
    ItemNamesSizeBytes + AttributeNamesSizeBytes + AttributeValuesSizeBytes

计算计费存储

计算计费存储大小需要三个额外的 DomainMetadata 值,它们是计数:ItemCount、AttributeNameCount 和 AttributeValueCount。这些数字代表您存储的与索引条目相对应的数据计数。每个索引条目都会产生 45 字节的存储费用,仅用于计费目的。计费存储的公式为:

indexStorage = 45 x (ItemCount + AttributeNameCount + AttributeValueCount)
billingStorage = baseStorage + indexStorage

注释

不要被“属性值对”语言所迷惑。这只是为了区分相同但使用不同属性名称存储的属性值。例如,如果您在项目中存储以下两个属性对:{name: "Violet", favColor: "Violet"},您将需要为存储这两个值“Violet”付费,因为它们是不同属性值对的一部分。如果文档说您需要为每件商品的每个唯一值付费,则对于此示例而言,它是不准确的。

此外,SimpleDB 中存储的所有数据都存储为 UTF-8 编码的字节字符串。出于所有目的(域元数据响应、配额执行和计费),编码为多个字节的所有字符都将计为多个字节。

除了字符编码之外,REST 请求还必须通过网络进行 URL 编码。这种“百分比编码”使各种字符的大小增加了三倍,例如,空格字符“ ”变为“%20”。此编码对存储大小计算没有影响。它在存储之前在 SimpleDB 端进行解码。

DomainMetadata 值有时从缓存提供,但通常不到 24 小时。检查响应中的时间戳以查看计算值的时间。实际上,这意味着大多数时候您无法添加一些数据并立即看到 DomainMetadata 值发生变化。

There are two different storage sizes for each domain. The base size includes only the base data that you have stored and is used by the SimpleDB service to when enforcing size quotas (10GB per domain, 1MB response from Select). The other size number is used only for billing purposes and also includes storage used behind the scenes for indexes. All 6 of the values you need to calculate both storage numbers are available from the DomainMetadata operation.

Computing the base storage

Only three of the values are needed to calculate the base storage:
ItemNamesSizeBytes, AttributeNamesSizeBytes and AttributeValuesSizeBytes. These values represent the sums of unique item name lengths, unique attribute name lengths, and all attribute value lengths. The formula for base storage is:

baseStorage = 
    ItemNamesSizeBytes + AttributeNamesSizeBytes + AttributeValuesSizeBytes

Computing the billing storage

Three additional DomainMetadata values are needed to compute the billing storage size, they are the counts: ItemCount, AttributeNameCount and AttributeValueCount. These numbers represent the counts of data you have stored that correspond to index entries. Each index entry incurs a 45 byte storage charge for billing purposes only. The formula for billing storage is:

indexStorage = 45 x (ItemCount + AttributeNameCount + AttributeValueCount)
billingStorage = baseStorage + indexStorage

Notes

Don't be confused by the "attribute-value pair" language. This is just meant to differentiate between attribute values that are the same but that are stored with different attribute names. For example, if you store the following two attribute pairs in an item: {name: "Violet", favColor: "Violet"} you will be charged for storing both values "Violet" because they are part of different attribute-value pairs. If the documentation said that you would be charged for each unique value per item, it wouldn't be accurate for this example.

Also, all data stored in SimpleDB is stored as UTF-8 encoded byte strings. All characters that encode to multiple bytes will count as multiple bytes for all purposes (DomainMetadata responses, quota enforcement and billing).

In addition to the character encoding, REST requests must be URL encoded over the wire. This "percent encoding" triples the size of various characters, e.g. the space character ' ' becomes '%20'. This encoding has no effect on storage size calculations. It is decoded on the SimpleDB side before storage.

The DomainMetadata values are sometimes served from a cache but are usually less than 24 hours old. Check the timestamp in the response to see when the values were computed. As a practical matter, this means that most of the time you won't be able to add some data and immediately see the DomainMetadata values change.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文