1
votes

I have a dynamodb table.

It has Primary partition key - IdType (String) and Primary sort key - Id (String)

As it's hash range schema, IdType is not unique and one key can be multiple times. I need to find all the unique IdType.

How do we find that? One possible solution is to get all IdType using Scan and process all client side and find unique using our own code. But scan is expensive and scan only limits to 1MB data per scan so it is not feasible to scan as the table is already more than 1 MB data and it will gradually increase in future.

Is there any other way to do this? Any help would be appreciated.

PS: There are no indexes

1

1 Answers

1
votes

Short answer would be NO, to query DynamoDB table the first thing you need is the Hash key so this eliminates all the options of Querying data because you must have hash key to find the data.

As far as I know DyanmoDB does not have any inbuilt attribute for finding a uniqueness of a key.

If you want to achieve this you can do it by

1) Scanning the table as you have mentioned and filter it at an application level.

2) If your data is not updated frequently then you can store the data in cache and retrieve the desired information

3) You can use another AWS service called cloudSearch to achieve the desired result (have to pay more)

If you are able to achieve with another method please do share it.

Hope that helps