How can I Use begins_with method on primary key in DynamoDB?

后端 未结 3 1645
囚心锁ツ
囚心锁ツ 2021-01-17 10:02

I have Table with 2 attribute id(string,primary key), value(string). When I try follwoing KeyConditionExpression it throws Query key condition not supported

相关标签:
3条回答
  • 2021-01-17 10:35

    I would stay away from scans at all costs, in this scenario I would create a global secondary index. The primary key on a GSI doesn't require uniqueness and you can query off of that. Storage is cheap, you can probably live with the extra keys.

    0 讨论(0)
  • 2021-01-17 10:37

    You can use begins_with and contains only with a range key after specifying an EQ condition for the primary key.

    To use EQ with the primary key you can do

    KeyConditionExpression: "ID = :tagIDValue"
    
    0 讨论(0)
  • 2021-01-17 10:55

    I disagree with Tolbahady statement regarding begins_with and contains only workable in range key. You can use any comparison operator in any keys using method scan. Scan is a flexible but expensive and inefficient way of conducting dynamodb queries.

    Anyways, there is a tool named, AWS NoSQL Workbench. It is little bit like MySQL Workbench. What is the good thing about it, is you can construct your table while checking against your access patterns(possible and most used queries of your application against your table).

    0 讨论(0)
提交回复
热议问题