R J
R J

Reputation: 4563

ItemSize in DynamoDB Global Index

There is already a question about how to calculate the size of items in dynamodb tables. But, it is unclear to me based upon the documentation I have read so far how to calculate the item size of items returned by a query on a global index.

Is it the size of all the attributes of the item in the table or the size of only all the attributes of the item projected into the index?

So far, I have found the following material:

For Query and Scan operations, DynamoDB calculates the amount of consumed provisioned throughput 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 will be the same whether you request all of the attributes (the default behavior) or just some of them using the ProjectionExpression parameter. -- AWS Reference

For Query, all items returned are treated as a single read operation. As a result, DynamoDB computes the total size of all items and then rounds up to the next 4 KB boundary. -- AWS Reference

The data in a secondary index consists of attributes that are projected, or copied, from the table into the index. When you create a secondary index, you define the alternate key for the index, along with any other attributes that you want to be projected in the index. DynamoDB copies these attributes into the index, along with the primary key attributes from the table. You can then query or scan the index just as you would query or scan a table. -- AWS Reference

Does anyone know the answer?

Upvotes: 2

Views: 944

Answers (1)

mkobit
mkobit

Reputation: 47249

It is based on the size of the index entry.

From the GSI Throughput Considerations documentation (emphasis mine):

For global secondary index queries, DynamoDB calculates the provisioned read activity in the same way as it does for queries against tables. The only difference is that the calculation is based on the sizes of the index entries, rather than the size of the item in the table. The number of read capacity units is the sum of all projected attribute sizes across all of the items returned; the result is then rounded up to the next 4 KB boundary. For more information on how DynamoDB calculates provisioned throughput usage, see Specifying Read and Write Requirements for Tables.

Upvotes: 1

Related Questions