The items that I write to my table don't appear in the related global secondary index (GSI) in Amazon DynamoDB. Or, there's latency between when I write the items and when I can read them in the GSI.
Resolution
Write operations propagate to a GSI within 1 second. If you wait several seconds and the GSI still doesn't show your updates, then check for the following common causes:
- Large base tables with many items or multiple GSIs on a single table that cause propagation latency.
- Items that are added in the base table that have no value for the GSI primary key.
Note: These items don't appear in the index because the GSI is a sparse index.
To resolve high propagation latency, configure your AWS SDK to use an exponential backoff algorithm. Then, retry the query or scan operations on the index. Exponential backoff gives the index time to show write operations and reduces the total number of required retries.
For tables with provisioned capacity mode, an index that has a lower write capacity than its base table can cause propagation delays. To resolve this issue, use the UpdateTable API to make the index write capacity equal to or greater than the base table capacity.
Related information
Data synchronization between tables and Global Secondary Indexes