Theoretically the getItem latency in dynamodb should be lower than query in dynamodb. but I am getting higher latency for get. Partition is not very large just 5-6 items of small size.
Query Latency : Max Avg is around 48
Get Latency: Max Avg is around 61
I understand average may not be the best parameter to judge, but I have also seen the maximum values for GetItem higher than Query.
Theoretically the getItem latency in dynamodb should be lower than query in dynamodb. but I am getting higher latency for get. Partition is not very large just 5-6 items of small size.
Query Latency : Max Avg is around 48
Get Latency: Max Avg is around 61
I understand average may not be the best parameter to judge, but I have also seen the maximum values for GetItem higher than Query.
Share Improve this question asked Mar 17 at 14:11 Ankit AabadAnkit Aabad 1552 silver badges5 bronze badges2 Answers
Reset to default 1Checking latency of DynamoDB when you only make a couple of requests is not going to give you obvious latency variance.
In reality Query and GetItem will have similar performance when Query is only returning a small number of items, as Query will only read a contiguous block on disk.
Latency in a large distributed system such as DynamoDB can vary by a couple of milliseconds here or there. A more accurate test would be to run a load test for a duration of 5 minutes using each method.
It could be due to many things, hard to tell, specially without knowing the access pattern and without seeing the entire code. I'd start with these:
Check if you are passing the same values of
ConsistentRead
to both Get and Query, that's one parameter that can impact latency.Compare the size of the response payloads for
GetItem
andQuery
. A larger payload (item size) could be makingGetItem
slowerAny network overhead you might be having while using
GetItem
?Are you reading from the same table, same region?
The number of GetItem vs Query calls seems to be low to make the assumption that one has lower latency than the other. Do you have a way to run a load test?