I'm using boto3 with python, but I belive the problem and logic should be universal across all languages.
I know that table.scan()
should in theory return all the records, but in fact, they scan() results are limited to 1MB in size. It's recommended to create a while loop based on LastEvaluatedKey
, but that also doesn't give me all the results (15200 instead of 16000), code here:
dynamodb = boto3.resource('dynamodb', region_name='eu-west-2')
table = dynamodb.Table(dBTable)
response = table.scan()
print("item_count:", table.item_count)
print("response1:", response["Count"])
items=[]
while 'LastEvaluatedKey' in response and response['LastEvaluatedKey'] != "":
print("response:", response["Count"])
items+=response["Items"]
response = table.scan(ExclusiveStartKey=response['LastEvaluatedKey'])
How can I fetch all the records reliably?