DynamoDB PartiQL vs. Scan

0

Hello,

Is there a rule for the PartiQL queries on DynamoDB Sort Keys (e.g. indexes on SK) ?
The below query does not return anything from Table1 with Sort Key Table1SK and with condition on SK, while a scan on same table with filter 'level1#level2#level3#' on SK, returns records.

select Table1SK
from Table1
where begins_with("Table1SK", 'level1#level2#level3#')

Thank you,
Mihai ADAM

  • please accept the answer if it was helpful

已提問 4 個月前檢視次數 234 次
1 個回答
0

To correctly query using PartiQL, ensure you include the partition key:

SELECT Table1SK
FROM Table1
WHERE Table1PK = 'somePartitionKey' AND begins_with(Table1SK, 'level1#level2#level3#')

Here, Table1PK should be replaced with the actual partition key attribute name and 'somePartitionKey' with the specific partition key value you want to query.

profile picture
專家
已回答 4 個月前
profile pictureAWS
專家
已審閱 4 個月前
  • Hi,

    Can the query be like below, or if multiple PKs needed, the only choice is to use few, with IN, OR clauses :

    SELECT Table1SK FROM Table1 WHERE begins_with(Table1PK, 'somePartition') AND begins_with(Table1SK, 'level1#level2#level3#')

    Thank you, Mihai ADAM

  • I'm not sure

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南