I am using AWS.DynamoDB.DocumentClient. I want to iterate over the items and conditionally update them.
I have a table which contains 4000 items. When I scan the table, even if I use ProjectionExpression, I get only 480 results. This is because of scan size limit (1 MB). I'm pretty sure if I get only partition keys, it will be less than 1 MB.
There are some similar questions about scanning specific items. But that's not what I struggle. What can I do to list all partition keys of my table? Thanks.
Here is my scan operation;
docClient.scan({
TableName: "Recipes",
"ProjectionExpression": "#key",
"ExpressionAttributeNames": {
"#key": "id"
}
}, async (err, recipes) => {
console.log("scanned recipes:" + recipes.Items.length)
//output: 477 (but the list have 4000 items)
}
Can you show the
scan
operation you've tried but isn't working for you?The following worked for me (my partition key is named PK)
Keep in mind that DynamoDB will consider the entire item size when calculating the 1MB limit, even if you use a projection expression that limits the response to just a few attributes. If your
scan
result returns aLastEvaluatedKey
, you know that DynamoDB is paginating the results.