之后不能为其他数据创建唯一的分区键

时间:2022-06-25 01:28:33

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."

我是AWS dynamoDB的新手。在我的研究中,我遇到了一个场景,“把它想象成一个在柜员窗前排成一排的银行。如果每个人都在一个出纳员排队,那么可以为更少的顾客提供服务。在不同的柜员窗口分配顾客会更有效率。用于分发客户的良好分区密钥可能是客户编号,因为每个客户都有所不同。“

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

我有一个问题,如何找出每个出纳员遇到的客户编号与同一个表(客户编号作为分区键)。

1 个解决方案

#1


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.

上述句子的解释是关于DynamoDB存储分发如何发生以及它如何影响数据查询。假设分区键作为单独的数据库服务器。当您只有一个分区密钥时,所有查询都会转到该服务器,从而提高其利用率,从而限制单个服务器的吞吐量。如果您有多个分区键,则内部DynamoDB可以从多个服务器并行查找项目,而不会遇到单个分区服务器瓶颈。

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.

如果将数据存储在名为Customers的DynamoDB表中,只有客户编号作为主键,要查找特定的出纳员,则需要扫描整个DynamoDB表,这是非常低效的。

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.
  • 如果您的查询涉及给定的客户编号和柜员ID以查找柜员信息,您可以重新创建具有柜员ID作为排序密钥的表(如果它对您的数据模型有意义),以便您可以直接查询柜员特定客户的信息。

#1


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.

上述句子的解释是关于DynamoDB存储分发如何发生以及它如何影响数据查询。假设分区键作为单独的数据库服务器。当您只有一个分区密钥时,所有查询都会转到该服务器,从而提高其利用率,从而限制单个服务器的吞吐量。如果您有多个分区键,则内部DynamoDB可以从多个服务器并行查找项目,而不会遇到单个分区服务器瓶颈。

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.

如果将数据存储在名为Customers的DynamoDB表中,只有客户编号作为主键,要查找特定的出纳员,则需要扫描整个DynamoDB表,这是非常低效的。

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.
  • 如果您的查询涉及给定的客户编号和柜员ID以查找柜员信息,您可以重新创建具有柜员ID作为排序密钥的表(如果它对您的数据模型有意义),以便您可以直接查询柜员特定客户的信息。