Querying an non primary key Attribute in DynamoDB

Viewed 96

I'm developing an API using DynamoDB where ID is the partition/primary key and there is also another attribute called "name." My question is how do I map ID and name in the service layer when I'm taking name as the input in the controller? I have tried using composite key and I cant use GSI nor LSI because they are costly. Please suggest me solutions other than what I've tried

1 Answers

Rethink your DDB design...

Assuming name is "user_name" and thus should be unique...

Then use that as a PK.

If name, is just name, then a GSI is your only option. Well I suppose you could use Scan() over the existing table...but for a large table, repeatedly doing a Scan() will be both slow and costly.

Related