gpt4 book ai didi

amazon-dynamodb - 从 DynamoDB 中删除具有相同分区键的大数据

转载 作者:行者123 更新时间:2023-12-03 16:18:53 24 4
gpt4 key购买 nike

我有这样结构的 DynamoDB 表

A   B    C    D
1 id1 foo hi
1 id2 var hello
A是分区键和 B是排序键。

假设我只有分区键,不知道排序键,我想删除所有具有相同分区键的条目。

所以我正在考虑通过查询加载具有固定大小(例如 1000)的条目并批量删除它们,直到 DynamoDB 中没有更多带有分区键的条目为止。

是否可以删除条目而不先加载它们?

最佳答案

https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DeleteItem.html
删除项目

Deletes a single item in a table by primary key.

For the primary key, you must provide all of the attributes. Forexample, with a simple primary key, you only need to provide a valuefor the partition key. For a composite primary key, you must providevalues for both the partition key and the sort key.


为了删除一个项目,您必须提供整个主键(分区 + 排序键)。因此,在您的情况下,您需要查询分区键,获取所有主键,然后使用它们来删除每个项目。您还可以使用 BatchWriteItem
https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchWriteItem.html
批量写入项目

The BatchWriteItem operation puts or deletes multiple items in one ormore tables. A single call to BatchWriteItem can write up to 16 MB ofdata, which can comprise as many as 25 put or delete requests.Individual items to be written can be as large as 400 KB.

DeleteRequest - Perform a DeleteItem operation on the specified item. The item to be deleted is identified by a Key subelement: Key -A map of primary key attribute values that uniquely identify the item.Each entry in this map consists of an attribute name and an attributevalue. For each primary key, you must provide all of the keyattributes. For example, with a simple primary key, you only need toprovide a value for the partition key. For a composite primary key,you must provide values for both the partition key and the sort key.

关于amazon-dynamodb - 从 DynamoDB 中删除具有相同分区键的大数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49684100/

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