I have a DynamoDB table where I need to query on two different attributes, sometimes by one, sometimes by the other one, but never by both at the same time.
Let's say I have an attribute A and attribute B, other attributes are irrelevant here.
I'm thinking of design this table with the Hash Key being the attribute A and a GSI being attribute B.
This way I always perform query
instead of scan
.
Now a question comes to my mind, which query is faster, on Attribute A (which is the Id) or on the Attribute B (GSI)?
If there is some difference I could switch, letting B as Id and A as GSI.
Thanks