The primary key is used to uniquely identify an item in a table, and all the queries made against the table are using the primary key. However, sometimes you require additional access patterns that would be inefficient with just the primary key. DynamoDB has the notion of secondary indexes that enable user to access these additional access patterns.
There are two types of Secondary Index:
- Local Secondary Index: A local secondary index uses the same partition key as the underlying table but a different sort key.
- Global Secondary Index: A global secondary index can define an entirely different primary key for a table.