Open thombergs opened 5 years ago
Paging for custom queries is in fact supported in SDN https://community.neo4j.com/t/pagination-and-sorting-with-custom-queries/1991 We should give it a shot.
EDIT:
Paging does indeed work in SDN. I implemented it for the project/{id}/commits
endpoint.
This is what the query looks like:
@Query(
value = "MATCH (p)-[:CONTAINS_COMMIT]->(c) WHERE ID(p) = {0} RETURN c ORDER BY c.timestamp DESC",
countQuery = "MATCH (p:ProjectEntity)-[:CONTAINS_COMMIT]->(c) WHERE ID(p) = {0} RETURN COUNT(c)")
@NonNull
Page<CommitEntity> findByProjectIdAndTimestampDescPaged(@NonNull Long projectId, @NonNull Pageable page);
I also implemented paging in the front-end and configured the paginators to load new pages on demand. However, clicking through the pages feels very sluggish and unresponsive. Considering we can load a lot of commits without pagination (maximum I've tried was 66655 commits) in a very short time and still browse them comfortably, I think we should discuss in what cases we need to page data and whether we even should.
Go through the HTTP endpoints and identify those that need paging.
Implement paging for these endpoints (see tutorial at https://reflectoring.io/spring-boot-paging/)