cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How does the LIMIT clause work?

Hi to everyone!

I am investigating the first order neighborhood of a node. The node can have an X total number of 1st order neighbors. I am limiting the query results via the LIMIT clause and I get, let's say Y neighbors. How does the LIMIT clause picks these Y neighbors out of the total population X?

I assume there is some sampling strategy running behind. If there is any resource I can get this kind of info regarding neo4j functions, procedures, etc. can you please share? It would be much appreciated!

  • Neo4j 3.5.16

Thanks!
Andreas

1 ACCEPTED SOLUTION

Hello @and.manousakis

By default, Neo4j uses its ids to sort the results (ascending id order) so in your case, it will return the node with the lowest identifier, if you want to sort the nodes, you can use ORDER BY + LIMIT:)

Regards,
Cobra

View solution in original post

2 REPLIES 2

Hello @and.manousakis

By default, Neo4j uses its ids to sort the results (ascending id order) so in your case, it will return the node with the lowest identifier, if you want to sort the nodes, you can use ORDER BY + LIMIT:)

Regards,
Cobra

Hi @Cobra, thank you for the reply! It does solve my problem. 🙂

Best
Andreas