全球二级索引是否存在热点问题

Do Global Secondary Indexes suffer from hot key issues

我知道 DynamoDB 中的表需要在分片之间均匀分布才能利用 read/write 容量,全局二级索引也是如此吗?

是的,GSI 与常规 table 索引具有相同的准则。您应该遵循 Guidelines for Working with Tables. The Guidelines for Global Secondary Indexes documentation 中描述的相同指导方针给出了一个示例,在该示例中,选择不当的密钥可能会导致热点和 activity 跨分区不均匀。:

For example, suppose you have an Employee table with attributes such as Name, Title, Address, PhoneNumber, Salary, and PayLevel. Now suppose that you had a global secondary index named PayLevelIndex, with PayLevel as the hash key. Many companies only have a very small number of pay codes, often fewer than ten, even for companies with hundreds of thousands of employees. Such an index would not provide much benefit, if any, for an application.

Another problem with PayLevelIndex is the uneven distribution of distinct values. For example, there may be only a few top executives in the company, but a very large number of hourly workers. Queries on PayLevelIndex will not be very efficient because the read activity will not be evenly distributed across partitions.