Create secodary indexes in DynamoDB example

#StandWithUkraine
Today, 18th May 2022, Ukraine is still bravely fighting for democratic values, human rights and peace in whole world. Russians ruthlessly kill all civilians in Ukraine including childs and destroy their cities. We are uniting against Putinโ€™s invasion and violence, in support of the people in Ukraine. You can help by donating to Ukrainian's army.

Each item in DynamoDB table consists of:

Fast query lookups are possible only on:

To enable fast query lookups on attributes we can create Global Secondary Index (GSI)

For example assume we have a table with game scores:

Game scores indexing

Target: Count total score by all games with one GameTitle:

As simple scan by GameTitle will be slow (because it is not hash key), we can create index GameTitleIndex which will give fast TopScores for certain GameTitle:

Secondary index

Results will be ranged(sorted) by range key.

Based on https://www.youtube.com/watch?v=qNhiFdDAWJU

#dynamodb #aws
0
Ivan Borshchov profile picture
Feb 28, 2017
by Ivan Borshchov
Did it help you?
Yes !
No

Best related