DynamoDB:本地二级索引可以稀疏吗

DynamoDB: can Local Secondary Indexes be sparse

我知道 GSI 可以是稀疏的,但是文档似乎没有提到 LSI - 它们也可以是稀疏的吗?

是的,他们可以。虽然 sparse indexes 文件明确提到了 GSI,但第一个例子:

For example, suppose that you have a table where you store all your customer orders, with the following key attributes:

Partition key: CustomerId

Sort key: OrderId

To track open orders, you can insert an attribute named isOpen in order items that have not already shipped. Then when the order ships, you can delete the attribute. If you then create an index on CustomerId (partition key) and isOpen (sort key), only those orders with isOpen defined appear in it.

正在谈论 LSI。索引分区键与 table 本身相同 (CustomerID).