Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DynamoDB: ReturnConsumedCapacity does not return RCU or WCUs

When writing to DynamoDB or reading from DynamoDB you can specify: ReturnConsumedCapacity.

When you do this the API does return total CapacityUnits, but I am not able to get it to return ReadCapacityUnits or WriteCapacityUnits. The documentation indicates we should indeed get data on RCUs and WCUs: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ConsumedCapacity.html

This is true whether or not you set ReturnConsumedCapacity to TOTAL or INDEXES.

This is also true if you are simply doing a read query too.

Is there anyway to get RCUs and WCUs returned?

Here is a sample query:

aws.exe dynamodb query \
    --table-name tableName \
    --index-name GSI1 \
    --key-condition-expression "GSI1PK = :pk" \
    --expression-attribute-value '{":pk": {"S": "blah"}}' \
    --return-consumed-capacity TOTAL

which returns something like this:

    "ConsumedCapacity": {
        "TableName": "tableName",
        "CapacityUnits": 128.5
    }

If I change the request from TOTAL to INDEXES I get:

    "ConsumedCapacity": {
        "TableName": "oaas-performance-table-dev",
        "CapacityUnits": 128.5,
        "Table": {
            "CapacityUnits": 128.5
        }
    }
}

pretty much the same in other words. No RCU or WCU.

Any idea how to get this additional data?

like image 629
Bob Woodley Avatar asked Oct 23 '25 08:10

Bob Woodley


1 Answers

This is the intended behavior, per the Query docs:

TOTAL - The response includes only the aggregate ConsumedCapacity for the operation.

A query can only consume read capacity, so CapacityUnits is effectively the same thing as ReadCapacityUnits, and WriteCapacityUnits is always 0.

like image 185
Collin Dauphinee Avatar answered Oct 25 '25 21:10

Collin Dauphinee