Ends in
00
days
00
hrs
00
mins
00
secs
SHOP NOW

PRE-BLACK FRIDAY SALE - GET 20% OFF ALL REVIEWERS

Find answers, ask questions, and connect with our
community around the world.

Home Forums AWS AWS Certified Developer Associate Indexes in DynamoDB

  • Indexes in DynamoDB

  • theodosiostziomakas

    Member
    September 9, 2024 at 2:58 am

    Hello everyone,

    Can you please explain me what is the difference between Local and Global secondary indexes with an example? The following diagram confuses me.

    Thanks,

    Theo

  • Nikee-TutorialsDojo

    Administrator
    September 9, 2024 at 9:05 am

    Hello Theo,

    Thank you for posting here and we’re happy to assist you. Let me clarify the difference between Local Secondary Indexes (LSIs) and Global Secondary Indexes (GSIs).

    In Amazon DynamoDB, Local Secondary Indexes (LSIs) and Global Secondary Indexes (GSIs) serve to enhance your querying capabilities but cater to different needs.

    Local Secondary Indexes (LSIs) allow you to create indexes that include different sort keys while keeping the same partition key as your base table. For instance, imagine you have a table named Library with a primary key consisting of BookID (partition key) and PublishDate (sort key). You could set up an LSI if you want to query books by AuthorName but still keep BookID as the partition key. This index would enable you to find all books by a specific author within the same partition but sorted by PublishDate.

    On the other hand, Global Secondary Indexes (GSIs) offer greater flexibility by allowing you to define entirely different partitions and sort keys from those used in the base table. For the same Library table, suppose you want to efficiently query books by Genre and sort them by PublishDate. You would create a GSI where Genre serves as the partition key and PublishDate as the sort key. This setup lets you query all books of a particular genre and see them ordered by publication date, irrespective of the BookID.

    In short, Local Secondary Indexes (LSIs) are useful for adding alternative sorting options while using the same partition key from your base table. They are great for making specific queries within partitions. On the other hand, Global Secondary Indexes (GSIs) provide more flexibility with different partition and sort keys, allowing for a wider range of queries and sorting options across the entire table.

    Hope this helps in clarifying the difference between the two.

    Regards,

    Nikee @ Tutorials Dojo

  • theodosiostziomakas

    Member
    September 9, 2024 at 1:30 pm

    Thank you Nikee for your great explanation.

    Kind regards,

    Theo

Viewing 1 - 3 of 3 replies

Log in to reply.

Original Post
0 of 0 posts June 2018
Now