Home > Back-end >  Any downside of having SortKey for GSI in dynamoDB
Any downside of having SortKey for GSI in dynamoDB

Time:05-12

I want to create a DynamoDB table with a GSI. For this GSI, currently I need only PartitionKey because I want to query by only one attribute. But in future I may need to query by other attributes. So, I am thinking of adding a SortKey just in case if I need to query by another attribute in future. For now it can be empty or can have the same value as PK.

In GSI, are there any drawbacks of adding SortKey, if I am not planning to use it in foreseeable future? Thank you.

CodePudding user response:

The (probably very) minor downsides of this approach are:

  1. marginally higher storage costs and
  2. added developer overhead of having to provide the (currently meaningless) index SK as part of the primary Key in CRUD operations.
  • Related