1

What the difference in terms of cost and WCU between updating the whole element in the list and updating specific attributes in the list?

For example, Option A:

UpdateExpression="set list[0].field1 = :a, list[0].field2 = :b",
ExpressionAttributeValues={
  ':a': 'value a',
  ':a': 'value b',
},

Option B:

const object = {
 field1: 'value a',
 field2: 'value b',
}

UpdateExpression="set list[0]= :list",
ExpressionAttributeValues={
  ':list': object,
},

Which one will reduce the WCU?

1 Answer 1

1

DynamoDB's pricing document contains this wording:

A standard write request unit can write an item up to 1 KB. For items larger than 1 KB, additional write request units are required.

Importantly, the item size is mentioned, not the update's size, which suggests that it doesn't matter how many fields in the item you're modifying - it's only the size of the whole item that matters when it comes to pricing.

This document is even more explicit that this is indeed the case, where it explains how an UpdateItem operation is charged::

DynamoDB considers the size of the item as it appears before and after the update. The provisioned throughput consumed reflects the larger of these item sizes. Even if you update just a subset of the item's attributes, UpdateItem will still consume the full amount of provisioned throughput (the larger of the "before" and "after" item sizes).

This actually makes sense, by the way. To modify an item, DynamoDB internally needs to read, modify, and rewrite the entire item. They cannot generally modify the item in-place, and they are unlikely to keep an index of each item's internal structure.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.