最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

amazon web services - DynamoDB still reads all items when using KeyConditionExpression BETWEEN - Stack Overflow

programmeradmin5浏览0评论

My DynamoDB table schema is:

  • identifier (HASH KEY)
  • time (RANGE KEY)

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?

My DynamoDB table schema is:

  • identifier (HASH KEY)
  • time (RANGE KEY)

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?

Share Improve this question asked Jan 15 at 1:00 Tam Ho ChiTam Ho Chi 11 silver badge1 bronze badge 1
  • Tips for asking a good Structured Query Language (SQL) question – DarkBee Commented Jan 15 at 6:03
Add a comment  | 

1 Answer 1

Reset to default 2

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.

发布评论

评论列表(0)

  1. 暂无评论