skip to Main Content

Why does AWS Scan LastEvaluatedKey return values ​​even when the key does not exist?

My scan request is

  {
  "TableName": "tks-processtracker-dumper",
  "ExclusiveStartKey": {
      "Mykey": {
          "S": "AKeyThatDoesntExists"
      }
  },
  "Limit": 2000
  }

Even passing a key that does not exist in the table, scanning still returns values.

My question is, should it return values ​​even when the key doesn’t exist? and why?

2

Answers


  1. ExclusiveStartKey is essentially a pointer to a location on the storage medium.

    It doesn’t care if the item is there, it hashes the value you submit and that points to a location in disk and the Scan will proceed from that position.

    Login or Signup to reply.
  2. It’s an EXCLUSIVE start key…

    It doesn’t have to exist, as DDB starts reading at whatever item has the next higher value.

    In SQL it’d look something like

    select *
    from table
    where tableKey > :exclusiveStartKey
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search