Spring data dynamoDB is not using the Page object to fetch the results from dynamoDB. Spring data loads the data into memory and then processes the pages out of it and provides the desired page result.
Here is the open issue: https://github.com/derjust/spring-data-dynamodb/issues/232
DynamoDB doesn't support accessing random page result. It can only provide sequential access.
Even-though I need pagination, due to the above reason, I am not able to use Spring data because I do not know how much amount of data (KB/MB's) Spring loads into memory from dynamoDB. The more data you load at once, the more RCU's will be used by dynamoDB.
I need the information on how much data does Spring reads into memory? So that I would like to re-evaluate if I want to use Spring data or not.
Thanks in advance.
This actually depends on the DynamoDB mapper configuration. From what I can tell, all DynamoDBMapper results from a query or scan are paginated. See the below excerpt:
"A DynamoDBMapperConfig.PaginationLoadingStrategy enumeration value—Controls how the mapper instance processes a paginated list of data, such as the results from a query or scan:
LAZY_LOADING—the mapper instance loads data when possible, and keeps all loaded results in memory.
EAGER_LOADING—the mapper instance loads the data as soon as the list is initialized.
ITERATION_ONLY—you can only use an Iterator to read from the list. During the iteration, the list will clear all the previous results before loading the next page, so that the list will keep at most one page of the loaded results in memory. This also means the list can only be iterated once. This strategy is recommended when handling large items, in order to reduce memory overhead.
If you do not specify a pagination loading strategy for your mapper instance, the default is LAZY_LOADING."
See full docs here: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBMapper.OptionalConfig.html