0

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 enter image description here

Get Latency: Max Avg is around 61 enter image description here

I understand average may not be the best parameter to judge, but I have also seen the maximum values for GetItem higher than Query.

2 Answers 2

1

Checking 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.

Sign up to request clarification or add additional context in comments.

Comments

0

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:

  1. Check if you are passing the same values of ConsistentRead to both Get and Query, that's one parameter that can impact latency.

  2. Compare the size of the response payloads for GetItem and Query. A larger payload (item size) could be making GetItem slower

  3. Any network overhead you might be having while using GetItem?

  4. Are you reading from the same table, same region?

  5. 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?

3 Comments

Same Table, Same Region, ConsitentRead not being used. For my case data returned in query is always larger than getItem.
Any difference in the read access pattern between both? Maybe the Query API calls are easily cached internally by DDB and the Get not so easy.
Also, 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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.