Reputation: 7410
I've been looking for a while now and cannot find anything definitive that specifies whether or not including ReturnValue.ALL_OLD within DeleteItem and PutItem requests consumes additional capacity.
On the one hand, it would make sense that it would because I can easily imagine it having to perform a separate read (which would hit your RCU).
On the other hand, the response JSON does not look like it has a way to specify both consumed READ capacity AND consumed WRITE capacity. DeleteItem and PutItem both consume write capacity, however I would assume if specifying ReturnValue.ALL_OLD did consume additional capacity, it would be read and I don't see AWS just lumping the two together in one value.
And on the other, other hand, the AWS documentation for UpdateItem specifically says there is no additional capacity consumed as a result of ReturnValue and UpdateItem is a write-based operation, like DeleteItem and PutItem.
Use ReturnValues if you want to get the item attributes as they appear before or after they are updated. For UpdateItem, the valid values are:
NONE - If ReturnValues is not specified, or if its value is NONE, then nothing is returned. (This setting is the default for ReturnValues.)
ALL_OLD - Returns all of the attributes of the item, as they appeared before the UpdateItem operation.
UPDATED_OLD - Returns only the updated attributes, as they appeared before the UpdateItem operation.
ALL_NEW - Returns all of the attributes of the item, as they appear after the UpdateItem operation.
UPDATED_NEW - Returns only the updated attributes, as they appear after the UpdateItem operation.
There is no additional cost associated with requesting a return value aside from the small network and processing overhead of receiving a larger response. No read capacity units are consumed.
Does anyone have any information from AWS or know of a definitive source for this question?
Upvotes: 3
Views: 2450
Reputation: 7679
I know this to be true from my own experience, but I've put together a thorough answer so that you can be confident in it. Here are some relevant parts of the documentation, which I will follow with some comments on it.
UpdateItem (documentation)
You can also return the item's attribute values in the same UpdateItem operation using the ReturnValues parameter.
...
There is no additional cost associated with requesting a return value aside from the small network and processing overhead of receiving a larger response. No read capacity units are consumed.
The values returned are strongly consistent.
PutItem (documentation)
You can return the item's attribute values in the same operation, using the ReturnValues parameter.
...
The ReturnValues parameter is used by several DynamoDB operations; however, PutItem does not recognize any values other than NONE or ALL_OLD.
DeleteItem (documentation)
In addition to deleting an item, you can also return the item's attribute values in the same operation, using the ReturnValues parameter.
...
The ReturnValues parameter is used by several DynamoDB operations; however, DeleteItem does not recognize any values other than NONE or ALL_OLD.
I think there are a few things to note here.
ReturnValues
is always part of the same operation.ReturnValues
is used by several of the API methods, and it explicitly calls out the differences when there are differences. The documentation does not mention any difference in how ReturnValues
affects the consumed capacity.You can also run a simple experiment yourself to see if this is true.
Update: I did some manual testing, and I confirmed that a write with return values does not consume any RCU.
Upvotes: 2