Hi guys, I'm trying the MongoRepository paging feature, it seems that for every page request it's doing a query that retrieves the full result set and then it filter only the requested page, is this correct?
I'm asking because I have an use case where the result set could be possibly large and it seems a non scallable way of doing pagination, or maybe it's beyond the porpouse of this feature and I should implement a custom DAO with ranged queries to do the pagination using mongodb resources.
Any ideas?
The DAO:
Code:@Repository public interface ItemRepository extends MongoRepository<Item, ObjectId> { Page<Item> findByState(String state, Pageable pageable); }
The testing code:
Code:Page<Item> page01 = itemRepo.findByState("ACTIVE", new PageRequest(2, 10)); Page<Item> page02 = itemRepo.findByState("ACTIVE", new PageRequest(3, 10));
The debug log that shows that 2 full queries are made:
Code:2011-12-01 18:21:56,265 [main] DEBUG: org.springframework.data.mongodb.repository.query.MongoQueryCreator.complete - Created query { "state" : "ACTIVE"} 2011-12-01 18:21:56,283 [main] DEBUG: org.springframework.data.mongodb.core.MongoTemplate.doFind - find using query: { "state" : "ACTIVE"} fields: null for class: class com.latpro2.domain.entity.Item in collection: items 2011-12-01 18:22:30,034 [main] DEBUG: org.springframework.data.mongodb.repository.query.MongoQueryCreator.complete - Created query { "state" : "ACTIVE"} 2011-12-01 18:22:30,034 [main] DEBUG: org.sprinframework.data.mongodb.repository.query.MongoQueryCreator.complete - Created query { "state" : "ACTIVE"} 2011-12-01 18:22:30,056 [main] DEBUG: org.springframework.data.mongodb.core.MongoTemplate.doFind - find using query: { "state" : "ACTIVE"} fields: null for class: class com.latpro2.domain.entity.Item in collection: items


Reply With Quote
