gpt4 book ai didi

Querying dynamodb based on list of elements(基于元素列表的DynamoDB查询)

转载 作者:bug小助手 更新时间:2023-10-24 23:51:08 25 4
gpt4 key购买 nike



I'm working on a task where I need to translate fields based on system.
SystemA has it's specific fields and if I want to get SystemB's equivalent for it , I want to query and return result.

我在一个任务,我需要翻译系统的基础上领域的工作。SystemA有它的特定字段,如果我想得到SystemB的等价物,我想查询并返回结果。


I'm new to DynamoDB.Below is dynamodb structure I have.

我是第一次接触DynamoDB。下面是我拥有的DynamoDB结构。























Field_system(Partition) Target_system(Sort) Value
John_systemA SystemB Doe
Sam_systemA SystemB Smith


There could be few thousand entries per system which has different fields.

每个具有不同字段的系统可能有几千个条目。


My initial approach was to loop through list of fields from input and query dynamodb for each element and aggregate result. This would be better than scanning whole table.

我最初的方法是遍历来自输入的字段列表,并为每个元素查询DynamoDB并聚合结果。这比扫描整个表要好。


Is there a better approach or other ways to query for all elements in list at once.

是否有更好的方法或其他方法一次查询列表中的所有元素。


Appreciate feedback and suggestions

感谢反馈和建议


更多回答
优秀答案推荐


For all elements in a list you have a couple of choices.

对于列表中的所有元素,您有几个选择。



  1. If you know both PK and SK for the items, then you can do a BatchGetItem and return up to 100 items per request.



  2. If the sort key is unknown, you can do an ExecuteStatement which provides you the ability to do something that would be the equivalent of BatchQuery which is an API that does not exist. You can specify up to 50 partition keys in your request.



  3. Again if you have a list of partition keys and are looking for the most performant approach, then sending parallel Query operations per key is the best way to achieve it.




Based on your schema, you may need to create an index with Target System as the partition key.

根据您的架构,您可能需要使用Target System作为分区键来创建索引。


更多回答

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