Internal working of DynamoDB while Querying

235 Views Asked by At

How does read query works in dynamoDB? I know that it internally calculates the hash based on the partition key and finds out the in which partition the item is present. After finding the partition how do you find the specific location of the item/record. Does it scan the complete partition for that item. If it scans the complete partition then how is dynamoDB called a key value lookup store?

I have searched for that in AWS Documentation, It's quite fascinating that is not mentioned anywhere.

1

There are 1 best solutions below

2
jarmod On

A query returns all items with a given partition key value, ordered by sort key value. No, it doesn't need to scan the partition to do this because there is an internal index.

See Data distribution: Partition key and sort key:

it stores all the items with the same partition key value physically close together, ordered by sort key value.

I agree that it's difficult to find any AWS-supplied documentation that confirms that there is a partition-level index on pk+sk or discusses the implementation of the indexing (LSM, B-Tree etc.) Will update this answer if/when I find evidence.