6

I am working on a table, in which every item is approx. 3KB in size.

Now as per the docs, the read units are calculated in 4s - i.e. For every item less than 4 kb, it would be counted as 4KB, and occupy 1 read unit.


Let's say i have a table of 100 items, of 3kb each in size (total table = 300kb). I do a query, in which 50 items satisfy under the query condition, and they are returned to me.
Now, will the read units be counted like : 50 items of 3kb size (rounded to 4kb) = 200kb = 200/4 = 50 read units ?

Any help is appreciated! :) Thanks!

Ersoy
  • 8,816
  • 6
  • 34
  • 48
kartik
  • 550
  • 1
  • 6
  • 19

2 Answers2

4

Yes, if you read 50 items of 3K each with strongly consistent reads, the cost will be 50 units. If you do eventual consistent reads, the answer will be half - 25 units.

However, there is another important cost issue you should be aware of, if you are not already. You mentioned you actually have 100 items, but only retrieving half of them by using a "query condition". DynamoDB actually has two types of "conditions" on queries. One of them are called key conditions (KeyConditions or KeyConditionExpression) and the other is post-query filters (QueryFilter or FilterExpression). If you use key conditions, you will only pay for the retrieved items - as you hoped. But if you use filtering, you will pay for all items, not just for the retrieved items. So in your example you would be paying 100 units instead of 50.

Nadav Har'El
  • 11,785
  • 1
  • 24
  • 45
3

I think this should clarify the issue:

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.

When you do the query, you can specify a parameter ReturnConsumedCapacity to get the number of read capacity units consumed:

TOTAL — The response includes the aggregate number of read capacity units consumed.

It also depends if you use eventually consistent reads (by default for query) or strongly consistent:

  • for eventually consistent reads (1 unit is 2 reads): 200 / 4 / 2 = 25 units
  • for strongly consistent reads (1 unit is 1 read): 200 / 4 / 1 = 50 units
Marcin
  • 215,873
  • 14
  • 235
  • 294