Beginner3 min read

GSI vs LSI in DynamoDB

Both a Global Secondary Index (GSI) and a Local Secondary Index (LSI) let you Query by an attribute that isn't your table's key. They are not interchangeable — the differences decide which one a pattern needs.

What is the difference between a GSI and an LSI in DynamoDB?

A Global Secondary Index can use any top-level scalar attribute (String, Number, or Binary) as its partition key, gets its own capacity, and can be added anytime — but only serves eventually consistent reads. A Local Secondary Index keeps the table's same partition key with a different sort key, supports strongly consistent reads and shares the table's capacity, but must be created with the table.

The differences that matter

GSILSI
Partition keyAny scalar (S/N/B)Same as the table
Sort keyAny scalar (S/N/B)Any scalar (S/N/B)
When createdAnytimeTable-creation only
ConsistencyEventual onlyStrong available
CapacityIts ownShares the table's
Write propagationAsync (eventual)Synchronous (atomic)
Max per table20 (default, raisable)5 (hard)
10 GB partition capNoYes (per PK)

A rule of thumb

  • Need a different (e.g. look up orders by status instead of customer)? You need a GSI — an LSI can't repartition.
  • Need a second sort order within the same partition — an LSI keeps the table's exact partition key and only swaps in a different sort key — decided up front, with reads? An LSI fits.

The choice collapses to one question — which key are you changing:

YesNo, same PKnew sort keyNeed to queryanother way?Differentpartition key?GSILSIOwn partitionsEventual readsOwn capacityAdd anytimeShared partitionStrong reads OKShared capacityTable-creation only

Different partition key forces a GSI; a different sort key on the same partition is the only case an LSI fits.

In practice most teams reach for GSIs almost exclusively: they're addable later, independently scaled, and not subject to the 10 GB per-partition limit. Overload a single GSI's keys to serve several patterns — see single-table design.

If you're adding a GSI to kill a Scan, remember it has its own read/write capacity. Size that extra cost with the pricing calculator, and try DynoTable to inspect an index's projected attributes before you commit to it.

Updated