Does SDN have N+1 query issue?

In JPA ORM world, it's bad practice, and it's easy to find lots of discussion.

But I don't find any discuss in SDN.

Why is that?

I check the cypher log by enable debug log level, it actually generate many cypher query if I have relationship define in my entity.

No one?
@gerrit.meier
@michael_simons1

For fetching:
This depends on your domain. If the domain represents a directed, acyclic graph, SDN can do the query with one query. If there are cycles in your domain, SDN will do a data-driven approach to fetch all reachable nodes from the graph. This means that initially it will fetch the only the first level of a relationship and than cascade with multiple queries through the relationships of the related nodes.

For saving:
This is unrelated to cycles. SDN will first create the node you want to persist (1. query). After this, it will create or update the related nodes (2. query), than the relationships between them (3.-n queries). With a deeper relationship definition, this will be continued/repeated until every node and relationship was processed.
There are some steps that are domain depending: There will also be a removal of all relationships just before the persistence of newly created ones, if you don't have relationship properties defined between the nodes. This is because SDN cannot determine if there was a removal in the domain model. The only option is to re-create all relationships it knows about at the time of saving.
For same type relationships there are also batch operations in place to avoid creating multiple queries for multiple relationships between the same nodes.

More details can be found in the chapter about query generation in the reference documentation: Query creation :: Spring Data Neo4j

Thanks for reply

If there are cycles in your domain, SDN will do a data-driven approach to fetch all reachable nodes from the graph. This means that initially it will fetch the only the first level of a relationship and than cascade with multiple queries through the relationships of the related nodes.

I think this approach will cause N+1 issue, right?

With this issue

It perform even worse.

In our test, thousands of nodes will take 2 mins to complete, I only return 1 root node with 2~3 sub node.
In low memory machine it is even throw OOM error.

I can understand this is tech limit, but plz show some warning in runtime, at least in the document.