DynamoDb dynamic update update

When we do table.batch_writer()

boto3 API, does it insert or update it?

By update i mean partition key

, sort key are same

but others attributes

are not the same. I cannot find this in any documentation.

+3


source to share


1 answer


batch_writer

in Boto3 displayed on the batch input functions offered DynamoDB, as a service. This batch entry is specific to the PutItem and DeleteItem operations and does not include UpdateItem.

From the docs:

The BatchWriteItem operation places or deletes multiple items in one or more tables. A single call to BatchWriteItem can write up to 16 MB of data, which can contain up to 25 send or delete requests. Individual entries can be up to 400 KB in size.

Note

     

BatchWriteItem cannot update items. Use the UpdateItem action to update items.



To be clear, the PutItem Operation either inserts a new item or replaces an item uniquely identified by its key (for section only, or compound section + sort key depending on how the table was defined). Thus, you can think of replacing an item as updating it with non-keys, but it is more correct to think of it as a replacement rather than an update. Compare this to the UpdateItem API , which allows you to selectively manipulate the attributes of an item.

It's worth mentioning that even when using the Place and Delete functions, the Batch API is more limited than the individual calls to PutItem or DeleteItem because it does not support conditional entries. The BatchWrite API is really only useful for batch loading or batch deleting data to save network overhead in terms of HTTP headers, additional computational resources for generating and verifying SigV4 signatures, etc.

+2


source







All Articles