Is there any difference in terms of cost or performance between using multiple getItem calls:
Promise.all([
     client.getItem({ TableName, Key }).promise(),
     client.getItem({ TableName, Key }).promise(),
     client.getItem({ TableName, Key }).promise(),
   ]
to one batchGet call:
const params = {
  RequestItems: {
    'TABLE_NAME': {
      Keys: [
        {'KEY_NAME': {N: 'KEY_VALUE_1'}},
        {'KEY_NAME': {N: 'KEY_VALUE_2'}},
        {'KEY_NAME': {N: 'KEY_VALUE_3'}}
      ]
    }
  }
};
db.batchGetItem(params).promise()
                In terms of cost: No - both Operations consume the same number of Read Capacity Units.
In terms of performance: Yes - using multiple GetItem requests sends separate network requests for each of them and for BatchGetItem there is only one request, which should be quite a bit faster.
There is no real downside to BatchGetItem except for a slight increase in complexity when some items aren't found.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With