Search code examples
python-3.xamazon-web-servicesamazon-dynamodbdynamodb-queries

If you run a scan on DynamoDB with an AttributesToGet argument are you charged for the data footprint of every item or just the requested attributes?


Suppose you run the following code on a table with 1,000 items that are 400KB in size, and suppose that the attribute name for 'column1' + the actual data are 10 bytes:

import boto3
    
def get_column_1_items():
    dynamodb = boto3.resource('dynamodb')
    table = dynamodb.Table('DynamoTable')
    resp = table.scan(AttributesToGet=['column1'])
    return resp['Items']

Will you be charged for retrieving 1000 * 400 KB = 400 MB of data retrieval, or for retrieving 1,000 * 10B = 10KB by running this query?


Solution

  • Based on the doc,

    Note that AttributesToGet has no effect on provisioned throughput consumption. DynamoDB determines capacity units consumed based on item size, not on the amount of data that is returned to an application.

    You will be charged for retrieving 400 MB of data.

    Also be aware that a single Scan request can retrieve a maximum of 1 MB of data. So in order to retrieve 400 MB of data, you need multiple requests.