I am using DynamoDBEnchancedAsyncClient
to query DynamoDB
using GSI
and pagination
. Below is the code that I am using to achieve the same. I am trying to limit the number of pages emitted to the client using limit()
below in the SdkPublisher<Page<Customer>>
Flux.from(PagePublisher.create(query.limit(5)).items())
I am planning to provide the next subsequent pages to the client back using the lastEvaluatedKey
and exclusiveStartKey
mentioned at Docs > My doubt is when we limit the number of pages using limit()
, what exactly happens wrt the number of pages actually fetched from the DynamoDB
?
- Are all the pages that can accomodate the
1MB
perqueryresponse
limit are fetched fromDynamoDB
and then only the pages that are permitted afterlimit()
are sent back? - Only the number of pages
permitted by
limit()
are fetched from the DynamoDB?
if its #1
. Then wouldn't it be overhead or additional redundant effort of fetching pages again from the DDB, since the earlier pages would have been already fetched and we are just again fetching them using exclusiveStartKey
?