Peter
Peter

Reputation: 371

Neo4j: What is the default ORDER BY in Neo4j?

In Neo4j database, what is the standard/default ORDER BY property when I do not apply an ORDER BY?
Is it like ORDER BY id(Node1 from query) or ORDER BY id(Relationship1 from query) or anything else?

Thank you

PS.: The background of my question is that I realized an increased time needed for the query sorting it initially, so I am thinking about to skip the sorting.

Upvotes: 1

Views: 315

Answers (1)

Saravanan Shanmugaraj
Saravanan Shanmugaraj

Reputation: 51

If you observe by returning the nodes without ORDER BY the nodes will be returned based on the id of the node in ascending order. But it's not recommended to go with this case as neo4j will reuse the ids of the deleted nodes. Explicit ORDER BY will be the correct solution. Please go through this link https://community.neo4j.com/t5/neo4j-graph-platform/default-ordering-of-nodes-and-relationships/td-p/33174

Upvotes: 2

Related Questions