DynamoDB Scan and FilterExpression Pagination Boundary
0 reputation · 11 Aug 2023, 22:55 UTC
Pagination Behavior with Filter Expressions
When performing a Scan or Query operation in Amazon DynamoDB, the service applies FilterExpression criteria after the data is read from the disk but before the results are returned to the client. This creates a specific interoperability challenge between the Limit parameter and the resulting page size.
Because the 1 MB limit or the specified Limit value is applied to the items evaluated rather than the items that pass the filter, it is possible for a response to contain an empty item list while still providing a LastEvaluatedKey. This indicates that the service reached its processing boundary without finding any matching records in that specific segment.
- The
Limitparameter restricts the number of items evaluated. - The
LastEvaluatedKeyindicates more data exists to be scanned. - Filtered results may be empty despite the presence of a pagination token.
What is the recommended architectural pattern for ensuring a client receives a minimum number of filtered items per request without risking excessive Read Capacity Unit (RCU) consumption during deep pagination? How should the client handle the state when a LastEvaluatedKey is returned with zero items?