Item Reads

Items may be read from any partition in the replication group. Since the data is always written to primary partition - a read from the primary partition will always return the latest data. This read from primary partition is referred to as Strongly consistent read as it would always return the latest data.

Reads can also be carried out from the standby partitions or replicas. Items read from these secondary partitions may not return the latest item data. This is due to the replication lag between primary partition and the secondary partitions. This type of read is referred to as Eventually consistent read. DynamoDB supports both strongly consistent and eventually consistent reads.

item-reads

Read operatios

There are 3 ways in which you can read items from the table. First one is a table scan which is like a SQL “SELECT * FROM table”

Second one is single item read In the case of Simple primary key - single item read is like a SELECT * from table with WHERE clause to select the item with a given partition key; in case of composite kye, single item read requires both the partition key and the sort key

Third type of read is the multiple item read query that returns an item collection based on a given partition key and a sort key selection criteria.

read-types

Request Router

Recall that DynamoDB maintains the “hash to partition mapping details” in the table’s metadata. In this illustration you see the mapping metadata and the distribution of items across 2 partitons.

When an application makes a Read/Update/Delete API call, the call goes to a request router component of the DynamoDB service. Router gets the mapping information from mapping metadata and then routes the call to the correct partition.

Refer to the illustration below. if a get item call is made for Partition Key for item A, the call will be directed to partition 1. For Item C the call will be directed to partition 2. This is the default behavior with eventual consistency for read operation. In case of request for strongly consistent read the calls are routed to the primary partitions.

request-router