Using Limit
and LastEvaluatedKey
for pagination is a common practice with DynamoDB BUT it's important to notice that Limit isn't the number of records returned on your result set; rather this is the number of records analyzed on a query operation.
Have a look at the AWS documentation on Queries and the Limit property: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html#API_Query_RequestSyntax
The maximum number of items to evaluate (not necessarily the number of matching items). If DynamoDB processes the number of items up to the limit while processing the results, it stops the operation and returns the matching values up to that point, and a key in LastEvaluatedKey to apply in a subsequent operation, so that you can pick up where you left off. Also, if the processed dataset size exceeds 1 MB before DynamoDB reaches this limit, it stops the operation and returns the matching values up to the limit, and a key in LastEvaluatedKey to apply in a subsequent operation to continue the operation. For more information, see Query and Scan in the Amazon DynamoDB Developer Guide.
While this is a generally applied workaround to pagination it may lead to unexpected results on large datasets.