Reputation: 1
My DynamoDB table schema is:
I'm trying to improve the response time in a DynamoDB PartiQL query that uses a KeyConditionExpression and BETWEEN.
My 1st query is:
select * from "table_test" where identifier = "product_1" and time > "-1" limit=100
Because of limit=100
, DynamoDB automatically paginates results with LastEvaluatedKey:
[-1, 50000]
[50000, 100000]
[100000, 150000]
[150000, 200000] (focus on this partition, it takes 4 seconds)
[200000, null]
My 2nd query is:
select * from "table_test" where identifier = "product_1" and time between 150000 and 200000
Query #2 takes 10 seconds.
I don't know why query #2 still takes more time than query #1 for the partition 150000-200000.
My question is does DynamoDB still read all items before applying the "BETWEEN" condition?
Upvotes: -1
Views: 40
Reputation: 19883
PartiQL defaults to a Scan when 2 or more conditions are on the where clause. I suggest you use the Query API which will give you the performance you desire.
Upvotes: 2