I want to update an item in dynamodb using boto, and the way I do it, I need to get_item
it first anyways, then I change the item and put
it back, is there any difference, performance penalty or otherwise, to do it using update_item
and not put
.

- 18,665
- 21
- 103
- 138
2 Answers
I am not aware of any performance differences between the two. Anyway, with DynamoDB, you pay for guaranteed throughput.
This said, UpdateItem
allows you to edit only a specific subset of an item. Moreover, this is the only way to use atomic increments.
If you have a very big Item and want to update a single small field then you should use UpdateItem instead so spare WriteCapacity. But this is the main usecase.

- 6,840
- 1
- 37
- 48
Save the throughput and only update the fields that need to be updated. The only downside to update_item is that it's not available as a batch function.
Correction: As noted in the comments, Dynamo actually uses the largest record to calculate the write capacity so if you only update one field, it will still calculate the write based on the total size of the record that already exists, this also applies if you PUT a record with the same ID.

- 6,853
- 15
- 58
- 71
-
2``UpdateItem`` does not work to save throughput, only bandwidth. The consumed capacity units are computed based on the bigger of "before update" and "after update". See http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide/WorkingWithDDTables.html#CapacityUnitCalculations for more background on capacity units. – yadutaf Oct 16 '12 at 14:07
-
Guess I need to do some more reading :-) I thought the rule of thumb was for every ~1kb you would use 1 write, hence I assumed that if you have a large record of 10kb and you only needed to update a tiny field it would save you 9 writes. Thanks for the correction! – greg Oct 16 '12 at 17:25