Search⌘ K

Secondary Index Best Practices

Explore how to design and use DynamoDB secondary indexes effectively by applying best practices. Learn when to avoid LSIs, how to project attributes efficiently in GSIs, use sparse indexes, apply reversed sort keys for aggregation, and create replicas for specific user needs, helping you optimize query performance and capacity management.

Unless you want strongly-consistent reads and writes, it makes no sense to use LSIs. There are good reasons for avoiding LSI. The primary reason being the limit on the size of the item collection. You can’t have more than 10GB of data with the partition key. LSI also increases your partition size, which is not desirable.

Also, while using GSIs, we should be mindful of the projected attributes. If we ...