Clive Sargeant
Clive Sargeant

Reputation: 652

How to query DynamoDb StringSet attribute efficiently

i am trying to use dynamoDb in an Android app. i have an item in a table. this item has a StringSet attribute. let's say for argument's sake, that this string set contains one million items. what is the most efficient way of getting 4 random items out of this set? thanks regards clive

Upvotes: 0

Views: 474

Answers (1)

Kannaiyan
Kannaiyan

Reputation: 13055

You cannot have one million strings in a single record, there is a per record size limitation.

This is how you can solve it.

string (PARTITION KEY), sequentialnumber (RANGE KEY), any extra attributed for this record.

Generate 4 random numbers ( 1 to 1 million ) and query for records, with the string and random number to dynamo.

This would solve your problem.

It is not efficient to search a record with million of items inside inside it.

Upvotes: 1

Related Questions