How can I Use begins_with method on primary key in DynamoDB?
I would stay away from scans at all costs, in this scenario I would create a global secondary index. The primary key on a GSI doesn't require uniqueness and you can query off of that. Storage is cheap, you can probably live with the extra keys.
You can use begins_with
and contains
only with a range key after specifying an EQ condition for the primary key.
To use EQ with the primary key you can do
KeyConditionExpression: "ID = :tagIDValue"