Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does DynamoDb update anything if no changes have been made?

Does DynamoDb update a record if no changes have been made in an UpdateItemRequest?

For example, if the table contains a record as follows:

{
  "id": "1",
  "name": "alice"
}

And the update request is as follows:

String expression = "set #n = :n"
HashMap<String, String> expressionAttributeNames = new HashMap<>();
expressionAttributeNames.put("#n", "name");
HashMap<String, AttributeValue> expressionAttributeValues = new HashMap<>();
expressionAttributeValues.put(":n", AttributeValue.builder().s("alice").build());
UpdateItemRequest updateItemRequest =
        UpdateItemRequest.builder()
            .tableName(tableName)
            .key(key)
            .updateExpression(expression)
            .expressionAttributeNames(expressionAttributeNames)
            .expressionAttributeValues(expressionAttributeValues)
            .build();
dynamoDbClient.updateItem(updateItemRequest);

In this case the name remains "alice", nothing has been changed. Does DynamoDb treat this as an update or does it treat it as nothing? I am asking because I wonder if DynamoDb streams will be triggered with this request.

like image 743
px06 Avatar asked Oct 29 '25 12:10

px06


1 Answers

According to the documentation the stream will not be triggered if UpdateItem does not change any data in the item:

If you perform a PutItem or UpdateItem operation that does not change any data in an item, DynamoDB Streams does not write a stream record for that operation.

like image 121
antonku Avatar answered Nov 01 '25 01:11

antonku