2

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?

James Shapiro
  • 4,805
  • 3
  • 31
  • 46

1 Answers1

4

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.

jellycsc
  • 10,904
  • 2
  • 15
  • 32
  • What about Projection Expression? https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ProjectionExpressions.html – James Shapiro Jun 08 '20 at 00:40
  • 1
    @JamesShapiro Same thing since `AttributesToGet` is a just a legacy version of `ProjectionExpression` – jellycsc Jun 08 '20 at 00:43
  • Thanks, good to know. Is there any documentation you can point me to that confirms that? – James Shapiro Jun 08 '20 at 00:44
  • 2
    @JamesShapiro https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html#Scan.CapacityUnits – jellycsc Jun 08 '20 at 00:51
  • 2
    > DynamoDB calculates the number of read capacity units consumed based on item size, not on the amount of data that is returned to an application. For this reason, the number of capacity units consumed is the same whether you request all of the attributes (the default behavior) or just some of them (using a projection expression). The number is also the same whether or not you use a filter expression. – jellycsc Jun 08 '20 at 00:52