Skip to content

Indexes

  • Indexes create an alternative view of the table
  • There are 2 types of Indexes namely Local Secondary Index (LSI) & Global Secondary Index(GSI)
  • GSI allows to create a view using a different Partition and Sort Key
  • Some or all attributes can be projected in these indexes
  • AWS recommends to use GSIs by default and use LSI only where Stron Consistency is required

Local Secondary Index (LSI)

  • Created by using alternate Sort Key
  • LSI allows to create a view using a different Sort Key
  • Must be created with the Table
  • Max 5 LSIs per table are allowed
  • Shares the RCU & WCU of base table
  • Either ALL or Keys Only or specific Attributes can be projected in the LSI
  • Indexes are sparse indexes i.e. only items which have the attribute which LSI is projecting as non blank not null are part of LSI

Global Secondary Index(GSI)

  • Can be created by using an alternate Partition Key & Sort Key
  • Can be created anytime during Table's life cycle
  • By defaul 20 GSI/Per table are allowed
  • Uses its own WCU & RCU different than Table's
  • One can choose which attribute can be projected in the GSI
  • GSIs are always eventually consistent