For Dynamodb, Does setting KeySchema automatically create a primary index? Or need to use GlobalSecondaryIndexes to create index?
Question posted in Amazon Web Sevices
The official Amazon Web Services documentation can be found here.
The official Amazon Web Services documentation can be found here.
2
Answers
No, there is no primary index on a DynamoDB table. Setting the key schema creates a primary key.
If your primary key is composite, i.e. comprises both a partition key and a sort key, then you can retrieve items for a given partition key ordered by the sort key.
It’s not explicitly mentioned in the documentation that an index is created for Primary KeySchema. However, if we look at the access patterns using Sort Key, it can be easily understood that an internal index is maintained for supporting access patterns like begins_with.
Checkout this for more details in access patterns using Sort keys.
Creating an alternate sort key or local secondary index also support internal index argument for Primary KeySchema with Sort Key (like an index for alternate Sort key).