Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DynamoDB - Newly put items are not reflecting in scan

I have a problem with DynamoDB scan. I added new items to the table using putItem method.

[[AmazonClientManager ddb] putItem:request];

But when I try to fetch using scan using scan method, that item is not coming in the result.

DynamoDBScanResponse *response = [[AmazonClientManager ddb] scan:request];

I am getting the below response,

{Items: ( ),Count: 0,ScannedCount: 608,LastEvaluatedKey: {HashKeyElement: {S: U2575220130319062347000,N: (null),SS: ( ),NS: ( ),},RangeKeyElement: (null),},ConsumedCapacityUnits: 129,{requestId: 3GVT8PJGV4VB45IUPUA6KIN9URVV4KQNSO5AEMVJF66Q9ASUAAJG}}

But these items are showing in table, when I checked using AWS Console. Could anyone let me know what could be the issue?

Thanks.

like image 339
EmptyStack Avatar asked Sep 05 '25 20:09

EmptyStack


1 Answers

Scan API is eventual consistent. Eventual consistent read may not return most recent changes. There is a slight delay (not more than a few seconds).

Query API allows consistent option. You may use Query if that's an option for you.

Another possibility is that you may not have finished processing the results of the scan yet -- Scan needs to be repeated until LastEvaluatedKey is null.

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Scan.html

like image 104
w xiao Avatar answered Sep 08 '25 11:09

w xiao