是什么在DynamoDB BatchGetItem和查询之间的区别?区别、DynamoDB、BatchGetItem

2023-09-11 11:46:04 作者:18.今天很烦躁

我已经经历AWS DynamoDB文档,并为我的生活,也弄不清什么是batchGetItem()和Query()之间的核心区别。这两种检索的基础上,从表和索引的主键条目。唯一的区别是在检索项目的大小,但似乎并不像一个破土动工的差异。双方还支持有条件的更新。

I've been going through AWS DynamoDB docs and, for the life of me, cannot figure out what's the core difference between batchGetItem() and Query(). Both retrieve items based on primary keys from tables and indexes. The only difference is in the size of the items retrieved but that doesn't seem like a ground breaking difference. Both also support conditional updates.

在什么情况下,我应该用batchGetItem了查询,反之亦然?

In what cases should I use batchGetItem over Query and vice-versa?

推荐答案

在一言以蔽之: BatchGetItem工程表,并使用哈希键来标识要检索的项目。你可以得到高达16MB或100个项目在响应

In a nutshell: BatchGetItem works on tables and uses the hash key to identify the items you want to retrieve. You can get up to 16MB or 100 items in a response

查询工作表上,本地二级指标和全球二级指标。你可以在数据的响应最1MB。最大的区别在于查询支持过滤EX pressions,这意味着你可以请求数据和DDB将其过滤服务器端给你。

Query works on tables, local secondary indexes and global secondary indexes. You can get at most 1MB of data in a response. The biggest difference is that query support filter expressions, which means that you can request data and DDB will filter it server side for you.

您也许可以实现同样的事情,如果你想使用任何这些,如果你真的想要,但经验法则是你做了BatchGet当你需要从DDB​​批量转储的东西,你查询时,你需要缩小下来你想要的检索(和你想要发电机做繁重过滤数据你)。

You can probably achieve the same thing if you want using any of these if you really want to, but rule of the thumb is you do a BatchGet when you need to bulk dump stuff from DDB and you query when you need to narrow down what you want to retrieve (and you want dynamo to do the heavy lifting filtering the data for you).