Query that fetches all upstream and downstream nodes

(Sainath Tableaudev) #1

Hello,
I have a query that fetches both upstream and downstream nodes. But when I change the browser settings with initial display from 300 to 1000 the Neo4j UI crashes or goes page unresponsive.
Could anyone review the query and update me the right query that fetches all upstream nodes and downstream nodes.
Query:
MATCH (a)-[r]->(b)
WITH b, count(*) as size
// return only the ones where there are more than 100 upstream nodes
where size > 100
return collect(distinct(b))

UNION ALL MATCH (a)<-[r]-(b)
WITH b, count(*) as size
// return only the ones where there are more than 100 downstream nodes
where size > 100
return collect(distinct(b))

0 Likes

(M. David Allen) #2

Queries can return far more data than can fit into your browser memory. Typically Neo4j Browser limits to a few hundred the number of nodes that can come back to prevent problems from occurring, but they still can if the nodes & relationships are extreme in number.

You should try putting a LIMIT on your query, or returning non-graph data (like just properties instead of the nodes and relationships) to lessen how much your browser has to work with.

0 Likes

(Sainath Tableaudev) #3

Great! Thanks for the response!

Since Neo4j browser has limits in visualizing the graph, what is the Max possible node count that I can see it in Neo4j browser?

Does it have to do with Performance Optimization?

0 Likes

(M. David Allen) #4

I can't remember off the top of my head but I think it's maybe 300 or so?

This is a limit to how many nodes you can realistically visualize in browser. Putting 1,000 nodes on the canvas wouldn't really be useful, as it would consume a lot of browser memory and mostly make a big visual mess on the screen. The primary consideration is memory your browser has, really.

The limit for your dataset might be lower. For example if each node has a large number of properties on it, already with 100 nodes you might be pulling quite a lot of data.

1 Like