0

I'm new to AWS dynamoDB. In my research, I encountered a scenario, "Think of it like a bank with lines in front of teller windows. If everybody lines up at one teller, less customers can be served. It is more efficient to distribute customers across many different teller windows. A good partition key for distributing customers might be the customer number since it is different for each customer."

I have a question, how to find out the customer numbers encountered by each teller with the same table (customer number as partition key).

Mukesh Kumar
  • 172
  • 9
  • When you quote a person or a document, please provide attribution for the quote. The quote above appears to be from [here](https://stackoverflow.com/a/45581869/1695906). – Michael - sqlbot Oct 14 '17 at 13:33

1 Answers1

0

Think of it like a bank with lines in front of teller windows. If everybody lines up at one teller, less customers can be served. It is more efficient to distribute customers across many different teller windows. A good partition key for distributing customers might be the customer number since it is different for each customer.

What explains by the above sentence is regarding how DynamoDB storage distribution happens and how it affect querying of data. Assume a partition key as a separate database server. When you have only a single partition key, all the queries goes to that server increasing its utilization, limiting to the single server for throughput. If you have multiple partition keys, internally DynamoDB can find the items in parallel from multiple servers without hitting a single partition server bottleneck.

Customer numbers are the partition key, and tellers are row data So do I have to run the query on every customer number to find data of a particular teller?

If you store the data in DynamoDB table called Customers, only with the Customer number as the primary key, to find a particular teller, you need to scan the entire DynamoDB table which is highly inefficient.

If you only want to get a particular teller item queried directly.

  • If you want to query the teller information directly, only using the teller Id, create the Teller id as a Global Secondary index and query the index to find the Teller information.
  • If your query involves a given a Customer number and Teller id to find the Teller information, you can re-create the table having Teller id as a sort key (If it makes sense to your data model) so that you can directly query the Teller information for a particular customer.
Ashan
  • 18,898
  • 4
  • 47
  • 67
  • Thanks for explaining, but what I'm asking here is, do I have to go to all the customer numbers (partition keys) to get the information of a single teller? – Mukesh Kumar Oct 14 '17 at 09:09
  • What is the relationship between customer numbers and tellers? – Ashan Oct 14 '17 at 09:50
  • Customer numbers are the partition key, and tellers are row data So do I have to run the query on every customer number to find data of a particular teller? – Mukesh Kumar Oct 14 '17 at 09:57
  • I have updated the answer with details. Let me know if there are further clarifications. – Ashan Oct 14 '17 at 10:08