When I write a record to a table, PutItem returns a successful HTTP 200 response. But when I try to fetch the item in a read request, Amazon DynamoDB doesn't return the record.
Resolution
DynamoDB tables and local secondary indexes (LSIs) provide two read consistency options: eventually consistent and strongly consistent. The read option is set to eventually consistent by default.
The GetItem operation provides an eventually consistent read by default. An eventually consistent read might not be able to access data immediately after the data is written to the table. To get the latest data, wait for a short amount of time, then try your read request again.
To retrieve the latest data as soon as the write request completes, set the ConsistentRead parameter to true. This activates strongly consistent reads. Before you activate strongly consistent reads, consider the following:
- Strongly consistent reads might have higher latency.
- Strongly consistent reads aren't supported on global secondary indexes.
- Strongly consistent reads require twice as much throughput as eventually consistent reads. This means that strongly consistent reads cost twice as expensive as eventually consistent reads. For more information, see Pricing for provisioned capacity and Pricing for on-demand capacity.
For an example request that uses strongly consistent reads, see Retrieve item attributes.
Related information
PutItem
Read consistency