Member-only story

Understanding DynamoDB Indexes: A Deep Dive into Global vs Local Secondary Indexes

Allwin Raju
3 min readNov 7, 2024

--

Global Secondary Index (GSI)

A Global Secondary Index allows you to create a new index on attributes of the table, with a different partition key and sort key from the primary index.

Characteristics of GSI

  • Partition Key Flexibility: You can define a completely different partition key and sort key for the GSI compared to the table’s primary key. This means you can query data using different access patterns that might not match the original table’s primary key.
  • Global Scope: GSIs are not tied to the partition key of the base table and can span across all items in the table, regardless of the original partition key.
  • Provisioned Throughput: GSIs have their own provisioned or on-demand throughput settings separate from the base table, allowing them to scale independently.
  • Consistency: By default, GSIs use eventual consistency, although you can opt for strongly consistent reads if necessary.
  • Limit: You can create up to 20 GSIs per table.

Use Cases for GSI

  • Alternate Querying Pattern: GSIs are ideal for creating additional query access patterns that need different…

--

--

No responses yet