8

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?

rishabhjainps
  • 410
  • 1
  • 5
  • 14

1 Answers1

17

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.

Luke
  • 22,826
  • 31
  • 110
  • 193
Charles
  • 21,637
  • 1
  • 20
  • 44