0
0
AWScloud~3 mins

Why Secondary indexes (GSI, LSI) in AWS? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if you could find any piece of data instantly, no matter how you want to look for it?

The Scenario

Imagine you have a huge phone book, but it's only sorted by last name. Now, you want to quickly find all people living in a certain city or with a specific job title. Without extra sorting, you'd have to flip through every page manually.

The Problem

Manually searching through all entries is slow and tiring. It's easy to miss details or make mistakes. As the phone book grows, finding what you want takes longer and longer, making your work frustrating and inefficient.

The Solution

Secondary indexes act like extra sorted lists for your data. They let you quickly find items by different keys without scanning everything. This saves time and reduces errors, making your data searches fast and reliable.

Before vs After
Before
Scan entire table and filter results in code
After
Query using a secondary index to get results directly
What It Enables

Secondary indexes unlock fast, flexible queries on large datasets without slowing down your application.

Real Life Example

A shopping app uses a secondary index to quickly find all orders by customer ID or by order date, making the app responsive and user-friendly.

Key Takeaways

Manual searches through large data are slow and error-prone.

Secondary indexes provide alternate ways to quickly find data.

They improve performance and user experience in real applications.