CodePark/ questions / RDS, Aurora & DynamoDB
START PRACTICINGPRACTICE
Backend question · Cloud & AWS › RDS, Aurora & DynamoDB

Which statement about DynamoDB secondary indexes is correct?

A global secondary index can use a different partition key and can be added later, but it supports only eventually consistent reads

A GSI (global secondary index) has its own partition key and sort key. You can create it at any time. DynamoDB updates it asynchronously, in the background, so reads from a GSI are eventually consistent: they may briefly return old data. That is why "A global secondary index supports strongly consistent reads if you ask for them" is wrong.

An LSI (local secondary index) uses the same partition key as the table, with a different sort key. So "A local secondary index can use a different partition key from the table" is wrong. You must define an LSI when you create the table, so "A local secondary index can be added to an existing table at any time" is also wrong. An LSI does support strongly consistent reads.