Katya S
Katya S

Reputation: 1363

Why does DynamoDB simple deleteItem operation use 2 CapacityUnits?

I have a simple delete operation which goes like this:

{
  "TableName":"demo_events",
  "Key":{
    "category":{"S":"Demo"},
    "DynamoID":{"S":"164933868Slt1396454204"}
  },
 "Expected":{
    "category":{
      "Exists":true,
      "Value"{"S":"Demo"}
    }
 },
 "ReturnConsumedCapacity":"TOTAL",
 "ReturnItemCollectionMetrics":"SIZE"}

There is only a single item in database with that ID. The response is this:

{ 
  ConsumedCapacity: { 
    CapacityUnits: 2, 
    TableName: 'demo_events'
  },
  ItemCollectionMetrics: { 
    ItemCollectionKey: { 
      category: { S: 'Demo' } 
    },
    SizeEstimateRangeGB: [ 0, 1 ] } 
}

Shouldn't this only consume 1 write unit?

Many thanks.

Upvotes: 0

Views: 181

Answers (1)

Vivek Halder
Vivek Halder

Reputation: 93

For PutItem, UpdateItem, and DeleteItem, which write only one item, DynamoDB rounds the item size up to the next 1 KB. If you have other attributes in the item in addition to the key attributes, they all together could add up to more than 1 KB.

If there is a Local Secondary Index (LSI) on the table, DeleteItem would also delete the corresponding item from the LSI and item size would contribute to the total Write Capacity Units consumed. DeleteItem response returns an ItemCollectionMetrics when there is a LSI defined for the table. There seems to be a LSI defined for the table based on the sample response

regards

Upvotes: 1

Related Questions