DynamoDB表扫描的读取容量成本 [英] Read capacity cost of a DynamoDB table scan

查看:74
本文介绍了DynamoDB表扫描的读取容量成本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不清楚,在阅读文档后,在DynamoDB中使用过滤器进行扫描操作期间会消耗多少读取容量单位。例如,使用以下红宝石请求:

It's unclear to me, after reading the docs, how many read capacity units are consumed during a scan operation with a filter in DynamoDB. For example, with this ruby request:

table.items.where(:MyAttribute => "Some Value").each do |item_data|
   # do something with the item_data
end

我的理解是,这将导致进行表扫描,但DynamoDB将仅返回我感兴趣的项目。但是,如果我的表中有10000个项目,而其中只有5个是通过我的过滤器的项目,那么我是否仍在收费读取容量单位的数量?

My understanding is that this will result in a table scan but DynamoDB will only return the items that I'm interested in. But if my table has 10000 items, and only 5 of those items are what gets through my filter, am I still being "charged" for a huge number of read capacity units?

我用于过滤器的属性不是哈希,范围或二级索引。我刚刚不得不最近添加该属性,并且出乎意料,这就是为什么我不使用查询的原因。

The attribute I'm using for the filter is not a hash, range or secondary index. I've just had to add that attribute recently, and unexpectedly, which is why I'm not using a query instead.

推荐答案

简而言之,您将被收取扫描物品的总金额(而不是退回的物品总金额)。与查询(如您已经提到的)相比,扫描是一项昂贵的操作。

In short, you will be "charged" for the total amount of items scanned (not the total amount of items returned). Scan is, compared to query (as you already mentioned) an expensive operation.

值得一提的是事实当您在表上调用扫描时,并不意味着将扫描整个表。如果扫描项目的大小超过1MB的限制,扫描将停止,您必须再次调用它以扫描表的下一部分。

Worth mentioning is the fact that when you invoke a scan on a table, it does not mean that the whole table will be scanned. If the size of the scanned items exceeds the limit of 1MB, the scan stops and you have to invoke it again to scan the next portion of the table.

来自官方文档:


如果扫描项的总数超过最大数据集大小
限制1 MB,则扫描停止,结果以
a LastEvaluatedKey值的形式返回给用户,以便在随后的
操作中继续扫描。结果还包括超过
限制的项目数。扫描可能导致没有符合过滤条件的表数据。

If the total number of scanned items exceeds the maximum data set size limit of 1 MB, the scan stops and results are returned to the user as a LastEvaluatedKey value to continue the scan in a subsequent operation. The results also include the number of items exceeding the limit. A scan can result in no table data meeting the filter criteria.

扫描后对找到的项目应用过滤器,因此可以完全不影响吞吐量。

The filter is applied after the scan on the found items so it does not affect the throughput capacity at all.

如果您要定期执行这些操作,则可能值得考虑添加一些二级索引或优化散列和范围键。

If you are going to be performing these operations regularly, it may be worth considering an addition of some secondary indexes or optimizing the hash and range keys.

这篇关于DynamoDB表扫描的读取容量成本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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