admin管理员组

文章数量:1185673

From the dynamodb tables, I'm trying to get max sized item (top 3 with their ID) from the table. Is there a way that we can get the max sized item using scan or query. The table doesn't have any item size stored in a separate column

From the dynamodb tables, I'm trying to get max sized item (top 3 with their ID) from the table. Is there a way that we can get the max sized item using scan or query. The table doesn't have any item size stored in a separate column

Share Improve this question edited Jan 27 at 11:23 Harry asked Jan 27 at 11:21 HarryHarry 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 1

You can Scan the table, and run each item through an item calculator and keep a track of the largest items. If you use JS you can install this npm package:

https://www.npmjs.com/package/ddb-calc

You can easily build something in a different language if you do not use JS.

Another solution is to track the consumed WCU each time you insert or update an item, the larger the WCU consumed indicates the size of the item.

https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html#DDB-PutItem-request-ReturnConsumedCapacity

The same approach can be used for GetItem operations.

本文标签: how to find the max sized item from dynamodb tableStack Overflow