From http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#BatchOperations :
These batch APIs are implemented as wrappers around other non-batch DynamoDB operations. BatchGetItem invokes the GetItem for each item in the batch.
And from :
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html#CapacityUnitCalculations :
For BatchGetItem, each item in the batch is read separately, so DynamoDB first rounds up the size of each item to the next 4 KB and then calculates the total size. The result is not necessarily the same as the total size of all the items. For example, if BatchGetItem reads a 1.5 KB item and a 6.5 KB item, DynamoDB will calculate the size as 12 KB (4 KB + 8 KB), not 8 KB (1.5 KB + 6.5 KB).
So is there any advantage in terms of response time or anything else by using the batchGetItem api vs iterating over a list and calling the getItem api?
2
votes
1 Answers
3
votes
Yes, response time. BatchGetItem
retrieves items in parallel vs sequential for GetItem. But, there are some other considerations that may be relevant:
- You need to make sure your table(s) are setup with a decent amount of read units;
- Check the expected results - you may not get all items in your batch request, so you may need to request again.
Hope this helps.