AdvancedAbout 15 min

    Secondary Indexes & Rebalancing

    Read the full article on Substack

    7 min read.

    Compare local and global secondary indexes on partitioned data, then add a node and move whole partitions instead of rehashing every key.

    Think of it this way: A local index is like each library branch keeping a catalogue of only its own books: to find every book by one author you phone every branch. A global index is one catalogue split by author name: you call one office, but when a branch buys a book the right office has to be told.

    Request—nodes asked: 0
    Node 1Cars
    1 red2 blue3 red4 black
    Index: its own cars
    black → 4
    blue → 2
    red → 1, 3
    Node 2Cars
    5 white6 red7 blue8 black
    Index: its own cars
    black → 8
    blue → 7
    red → 6
    white → 5

    Cars are split by id across two nodes. Each node keeps an index of only its own cars.

    1/6

    Check your understanding

    Answer from memory before you scroll back up. Pulling an idea out of your head is what makes it stay there.

    Local or global index?

    Sort

    Sort each trait into the kind of secondary index it describes.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    Local index

    Drop items here

    Global index

    Drop items here
    6 pieces left to place

    Quiz

    8 questions
    Question 1 of 8
    Score: 0

    With a local secondary index, a search by that field must…

    Done with this lesson?

    Sign in free to keep your progress, streak and quiz scores.

    Keep going