DynamoDB Global Secondary Index (Gsi)

  • Provide you additional Primary Key (hash or range and hash) from the base table

    • Primary key consist of scalar attributes (String, Number or Binary)
  • Usage

    • Speed up queries on attributes that are not primary key
  • Attribute Projections

    • Can project some or all attributes from the base table (KEY_ONLY, INCLUDE, ALL)
    • If attributes is not projected with the index, we can't get it
  • GSI can be added and modified after table creation

  • Must provision RCUs & WCUs for the index

    • Have the option for autoscaling as well

Example
Pasted image 20221013104129.png
For example normally we can't just query based on Game_ID as the primary key on itself.

After creating GSI, we can query based on Game_ID, also we can optionally specify a sort key for example (Game_TS) to query based on Game_ID and Game_TS