amazon-dynamodbsecondary-indexes

Does DynamoDb allows duplicate sortKey in Index


Does DynamoDb allows duplicate sortKey in Global Secondary Index and Local Secondary Index.

I have a table with partitionkey and sortKey and want to introduce GSI and LSI with different sortKey attribute, can this attribute have duplicates?


Solution

  • Yes...

    GSI

    In a DynamoDB table, each key value must be unique. However, the key values in a global secondary index do not need to be unique.

    LSI

    In a DynamoDB table, the combined partition key value and sort key value for each item must be unique. However, in a local secondary index, the sort key value does not need to be unique for a given partition key value.