Does DynamoDB support secondary indexes?

Yes. DynamoDB supports two kinds of secondary indexes. A Global Secondary Index (GSI) has its own partition/sort key and capacity (up to 20 per table, eventually consistent). A Local Secondary Index (LSI) shares the table's partition key with a different sort key, supports strong consistency, and must be defined at table creation.

Global Secondary Index (GSI)

  • Its own partition and sort key, independent of the table's.
  • Its own provisioned throughput (or on-demand capacity).
  • Eventually consistent reads only.
  • Add or remove any time; default quota of 20 per table.

Use a GSI to query by attributes that are not the table's primary key.

Local Secondary Index (LSI)

  • Shares the table's partition key, with a different sort key.
  • Shares the table's throughput.
  • Supports strongly consistent reads.
  • Must be created at table creation and cannot be added later.

Choosing between them

Reach for a GSI for new access patterns and flexibility; reach for an LSI when you need strong consistency on an alternate sort within the same partition.

Go deeper

Compare them in GSI vs LSI and see index projections. Download DynoTable to query through your indexes.

Work with DynamoDB without the Console

DynoTable is a fast desktop client for DynamoDB — browse tables, run SQL-style queries, and edit items locally.