Querying with Secondary Indexes: GSIs and LSIs
Learn how Global and Local Secondary Indexes let you query DynamoDB by attributes other than the primary key, and how to choose between them.
The Primary Key Limitation
DynamoDB queries efficiently only by the primary key (partition key, optionally plus sort key). To query by other attributes you need a secondary index.
- Scanning the whole table is slow and costly
- Indexes give you efficient alternate access paths
What Is a Secondary Index?
A secondary index is an alternate view of your table data, organized by a different key. DynamoDB keeps it in sync automatically as you write to the base table.
All lessons in this course
- Introduction to DynamoDB
- Designing DynamoDB Tables
- Lambda & DynamoDB Integration
- Querying with Secondary Indexes: GSIs and LSIs