Global Secondary Index
Explore how global secondary indexes (GSIs) in DynamoDB enable efficient querying beyond the primary key. Learn to set partition and optional sort keys, decide which attributes to project, and understand GSI costs related to read and write capacity units. This lesson helps you optimize data queries and manage read/write efficiency in DynamoDB tables.
We'll cover the following...
We'll cover the following...
Example scenario
Imagine that we are creating a database for songs. We choose “Artist” as the partition key and “Song_title” as the sort key. The other attributes in the table are “Album”, “Genre”, and “Year”.
The envisioned database will look like this:
| Artist | Song | Album | Genre | Year |
|---|---|---|---|---|
| Pink Floyd | Comfortably Numb | The Wall | Progressive rock | 1979 |
| Pink Floyd | Mother | The Wall | Progressive rock | 1979 |
| The Beatles | Glass Onion | The Beatles | Psychedelic rock | 1968 |
| The Beatles | Hey Jude | 1 | Pop rock | 2000 |
| Metallica | Atlas, Rise! | Hardwired… to self-destruct | Metal | 2016 |