21
votes

Is it possible to have cypher query paginated. For instance, a list of products, but I don't want to display/retrieve/cache all the results as i can have a lot of results.

I'm looking for something similar to the offset / limit in SQL.

Is cypher skip + limit + orderby a good option ? http://docs.neo4j.org/chunked/stable/query-skip.html

2

2 Answers

21
votes

SKIP and LIMIT combined is indeed the way to go. Using ORDER BY inevitably makes cypher scan every node that is relevant to your query. Same thing for using a WHERE clause. Performance should not be that bad though.

6
votes

Its like normal sql, the syntax is as follow

match (user:USER_PROFILE)-[USAGE]->uUsage 
where HAS(uUsage.impressionsPerHour) AND (uUsage.impressionsPerHour > 100) 
ORDER BY user.hashID 
SKIP 10 
LIMIT 10; 

This syntax suit to last version (2.x)