DynamoDB Dynomite Querying Limit

You can limit the number of results with limit. Here are some chained examples.


Product.all.limit(2).map(&:name) # also works
Product.where(category: "Electronics").limit(2).map(&:name)

Limit Implementation

The limit is not sent to the DynamoDB as part of the query or scan operation. Dynomite sends paginated requests to the AWS API at the default limit sdk setting. AWS DynamoDB scans up to 1MB per page. Dynomite checks the limit at the Ruby level once the total count reaches the limit. From a developer interface perspective, I believe this is what the user would expect.