spring-data-couchbase
spring-data-couchbase copied to clipboard
Support selecting and counting in parallel in SimpleCouchbaseRepository#findAll(Pageable pageable)
We use something like this in our custom base repository:
final Mono<Long> totalCount = getReactiveCouchbaseOperations().findByQuery(getEntityInformation().getJavaType())
.withConsistency(buildQueryScanConsistency())
.matching(new Query().with(pageable))
.count();
final Mono<List<T>> pageContents = getReactiveCouchbaseOperations().findByQuery(getEntityInformation().getJavaType())
.withConsistency(buildQueryScanConsistency())
.matching(new Query().with(pageable))
.all()
.collectList();
// zip the two queries together to return the requested Page
return Mono.zip(pageContents, totalCount, (list, count) -> new PageImpl<T>(list, pageable, count))
.block();
Agreed. But the whole paging business needs to be revisited. Using limit and skip is not efficient. Paging should be key-based.