I am trying to build an application for agents who can have multiple locations. Below is what my data would look like.
| Partition Key | SortKey | AgentName | LocationAddress |
--------------------------------------------------------------
| Agent1 | Agent1 | AgentName | |
| Agent1 | Location#1 | | 123 MainStreet..|
| Agent1 | Location#2 | | 1 MainStreet.. |
| Agent1 | Location#3 | | 12 MainStreet.. |
I am expecting no more than 20 locations for each agent I am storing.
My use cases are the following
- Match each location with an external list (The external list will likely have all the stored location. Business use case is to validate the external list data against the database.)
Access pattern options:
- GetAll using PartitionKey="Agent1" and SortKey BEGINS_WITH="Location"
- GetItem using PartitionKey="Agent1" and EQ="Location#1"
- According to StackOverflow question, GetItem maybe a better choice having PartitionKey and SortKey here
In comparison, the link suggests that
The latency of GetItem vs Query with limit=1 will be equivalent.
You'd think the Query will be better in the case you need N number of locations in one go. The latency would 1 in that vs. latency would be N number of locations for GetItem.
After doing all my research I think that it might be better to take option #2 because of the throughput and knowing you'll need all data anyways.
Querying the DB once would be 1 throughput vs GetItem with throughput one every time you get the item. I would like to discuss if option #1 is better than option #2.