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

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

问题描述

在阅读文档后,我不清楚在 DynamoDB 中使用过滤器进行扫描操作期间消耗了多少读取容量单位.例如,对于这个 ruby​​ 请求:

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.

推荐答案

简而言之,您将被收取"扫描物品的总数量(而不是退回的物品总数量).Scanquery(正如您已经提到的)相比是一项昂贵的操作.

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,扫描停止并将结果返回给用户一个 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天全站免登陆