DynamoDB - Newly put items are not reflecting in scan

dynamodb scan all items
dynamodb scan order
dynamodb scan cost
dynamodb scan map
dynamodb scan index
api gateway dynamodb scan
dynamodb write consistency
scan filter

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.


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

Working with Scans in DynamoDB, If you need to search in any item's attribute in a DynamoDB table, use a scan to the Scan results might not reflect changes due to recently completed PutItem  In this case, DynamoDB applies the filter expression to the six items that were returned, discarding those that do not match. The final Scan result contains six items or fewer, depending on the number of items that were filtered.


Setting ConsistentRead to true works for me:

https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Scan.html#DDB-Scan-request-ConsistentRead

A Boolean value that determines the read consistency model during the scan:

If ConsistentRead is false, then the data returned from Scan might not contain the results from other recently completed write operations (PutItem, UpdateItem or DeleteItem).

If ConsistentRead is true, then all of the write operations that completed before the Scan began are guaranteed to be contained in the Scan response.

The default setting for ConsistentRead is false.

AWS Certified Developer Official Study Guide, Associate Exam: , If you perform a read operation on an item that does not exist, DynamoDB will still In addition, Query and Scan can return item counts instead of attribute values. not reflect changes as the result of recently completed PutItem or UpdateItem  The Scan operation returns one or more items and item attributes by accessing every item in a table or a secondary index. To have DynamoDB return fewer items, you can provide a FilterExpression operation.


Tutorial: Process New Items with DynamoDB Streams and Lambda , Working with Scans A new stream record is written to reflect that a new item has been added to BarkTable . If you have not done so already, follow the instructions in the AWS Command Line Interface User Guide to aws iam put-​role-policy --role-name WooferLambdaRole \ --policy-name WooferLambdaRolePolicy  Scanning a Table. Create a Node.js module with the file name ddb_scan.js. Be sure to configure the SDK as previously shown. To access DynamoDB, create an AWS.DynamoDB service object. Create a JSON object containing the parameters needed to scan the table for items, which in this example includes the name of the table, the list of attribute


AWS Certified Solutions Architect Official Study Guide: Associate Exam, The UpdateItem action will find existing items based on the primary key and replace the attributes. action or through a search using the Query or Scan action. the response might not reflect the results of a recently completed write operation. Scanning Tables and Indexes: Java The Scan operation reads all of the items in a table or index in Amazon DynamoDB. The following are the steps to scan a table using the AWS SDK for Java Document API.


Working with Items and Attributes, The basic building blocks of Amazon DynamoDB start with tables, items, and attributes. An attribute value can be a scalar, a set, or a document type. If an item with the specified key does not exist, UpdateItem creates a new item. Now consider the following diagram, showing how conditional writes would prevent  Scan DynamoDB Items With Node.js Tap into DynamoDB's scanning ability with some quick JavaScript. Be warned, though, that it might be more expensive than it's worth.


Service, Account, and Table Limits in Amazon DynamoDB, This section describes current limits within Amazon DynamoDB (or no limit, in some One write capacity unit = one write per second, for items up to 1 KB in size. The new settings do not take effect until the UpdateTable operation is complete. In other words, the total number of tables in the CREATING , UPDATING , or  The Scan call is the bluntest instrument in the DynamoDB toolset. By way of analogy, the GetItem call is like a pair of tweezers, deftly selecting the exact Item you want. The Query call is like a shovel -- grabbing a larger amount of Items but still small enough to avoid grabbing everything.