I know that when executing a get request, dynamodb would leverage the partition key to determine what partition the row is in. But, my question: what happens next? The docs say that if you have specified a sort key, then data within the partition would be sorted which means quick lookup. But let’s say if I haven’t specified a sort key. What happens next? I’d imagine it’s either one of the following but not sure which one is it:
-
there’s a separate lookup (ie O(1) operation) happening (again using partitionKey) within the partition. I’m not sure what hash function would be used here and how it would (or even could) be any different than the previous hash function.
-
DynamoDb scans through the data within the partition until it finds the row matching partitionKey (which seems painful). I’d pray that data would at least be sorted within partition by partition key else this seems like O(n) operation to me. A scan would conflict with popular opinion that DynamoDB is fast for all use cases (with single digit milliseconds latency).
I’m not seeing any docs around this specific case so would love to hear from DynamoDB experts here. Links would be appreciated.
Thanks in advance
2
Answers
DynamoDB requests are interpreted by a component called RequestRouter which contains a local cache of which partition your item exists.
Although not a direct answer, I want to contribute the following AWS video on how DynamoDB works under the hood. This video has taught me a lot in my career for building high throughput applications with DynamoDB. I hope it helps you out as well 🙂
https://youtu.be/yvBR71D0nAQ