1
votes

My question is if it make sense to limit returned attributes while doing a query / scan to dynamoDB.

I'm doing a query directly from Lambda and I'm fetching around 100 records in one go. After that I return a data to a UI using API gateway. I don't really need all the attributes so my question is - does it make sense to limit them? I.e. instead of getting:

{a,b,c,d,e,f,g}

i will request only

{a,b,c}

Will I save money by limiting size of transferred / requested / returned data or I will simply only reduce response size?

1

1 Answers

2
votes

No, you will not save money by projecting only a few attributes instead of the entire items, nor will you save any money by filtering out entire items (with a FilterExpression). As you put it, you will "only reduce response size".

Here is the relevant quote from the DynamoDB documentation, https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html

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. 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 a projection expression). The number will also be the same whether or not you use a FilterExpression.