gpt4 book ai didi

java - DynamoDBMapper : How to get all the rows for multiple id's(array) in a single query or scan of DynamoDBMapper

转载 作者:行者123 更新时间:2023-12-02 10:03:02 25 4
gpt4 key购买 nike

我的数据库表由多行组成,其 id 是唯一的。

API(Endpoint) -> 获取 id 的行我正在传递输入数组 (id1,id2,id3,id4)

Question : In DynamoDBMapper, write a single query fetching all the rows for the id's that we passed in.

我们可以使用扫描或查询。

感谢您的帮助。提前致谢。

最佳答案

扫描或查询不适合此交易。

您应该迭代您的列表并使用 GetItem单独检索每个项目,这是获取项目最快且最便宜的方式。您还可以使用BatchGetItem如果您希望执行并发请求。

扫描会很慢而且成本很高,因为它会评估表中的每个项目。但是,如果您坚持使用它,只需扫描您的表格并提供 ScanFilter退回您的元素。

如果您使用查询,它的操作方式将与 GetItem 完全相同。您必须迭代您的 ID 列表。即查询根本不适合这种情况。

关于java - DynamoDBMapper : How to get all the rows for multiple id's(array) in a single query or scan of DynamoDBMapper,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55496649/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com