Home > Net >  Why AWS Scan LastEvaluatedKey return values even when the Key not exist
Why AWS Scan LastEvaluatedKey return values even when the Key not exist

Time:10-08

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?

CodePudding user response:

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.

CodePudding user response:

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
  • Related