Local Secondary Index
What is Local Secondary Index?
Local Secondary Index
What is a Local Secondary Index (LSI)?
It’s an index we define that shares the table’s partition key but uses an alternate sort key for scans and queries. It must be created at table creation time you cannot add, remove, or modify it later. All queries based on that sort key are significantly faster using the index than the main table.
AWS Developer: Local Secondary Indexes (LSIs)
DynamoDB: Scan vs Query
Choose an operation below and interact with the data to see exactly what DynamoDB searches and returns.
Scan the Users table
A Scan looks through the table. Optionally choose a value to filter the results.
DynamoDB scans:
Users
→
Every item
→
Filter
→
Results
DynamoDB operation
Returned data
Users Table
The base DynamoDB table
| UserId Partition Key | CreatedAt Sort Key | Name | |
|---|---|---|---|
| user-123 | 2026-09-01 | alice@example.com | Alice |
| user-456 | 2026-09-05 | bob@example.com | Bob |
| user-789 | 2026-09-10 | john@example.com | John |
EmailIndex
Same partition key, different sort key
| UserId Partition Key | Email LSI Sort Key |
|---|---|
| user-123 | alice@example.com |
| user-456 | bob@example.com |
| user-789 | john@example.com |
This post is licensed under
CC BY 4.0
by the author.