Local Secondary Index
Explore how local secondary indexes (LSIs) enable filtering DynamoDB queries by attributes other than the primary key. Learn how LSIs reduce resource consumption by creating indexed projections and understand their creation, limitations, and practical use cases.
There could be scenarios where we need to look for records that match particular attributes that aren’t part of the primary key. This could lead to performance or consumption issues. Let’s explore a solution to this problem called the local secondary index.
Queries with specific attributes
When a record is stored, it has a partition key and, perhaps, a sort key. Let us imagine there is a table with different records, and you are required to find a particular record based on its key. That shouldn’t be a problem, as we can simply send a query with the record’s key. A problem could occur if you’re asked to look for records where an attribute matches a particular criteria that isn’t related to the record’s partition key.
The image above shows that DynamoDB is going to read all records with the ...