1
votes

I would like to list all relations inside my graph of around 20000 edges, with the cypher query MATCH ()-[r]-() RETURN r. For each relation I would like to get the relation type, its properties, the source node ID, the target node ID.

When I run this query on the neo4j client interface, the results appear pretty fast in a few seconds.

However, when I call this query with py2neo with Graph.run("MATCH ()-[r]-() RETURN r") it takes a super long time to just loop on the results, without any processing.

Do you know why is that ?

2

2 Answers

1
votes

If you haven't upgraded to the latest release, do so. There were some significant performance improvements added for reading results in the last patch.

1
votes

Your query is actually doing extra work. Because your relationship isn't directed in the pattern, it's returning twice for each relationship, just with the start and end nodes flipped (remember that paths consist of ordered nodes, so with the order flipped you will get two distinct paths per pairing).

Your query should go a little faster (less data to return) if you add the direction:

Graph.run("MATCH ()-[r]->() RETURN r")

Also, the Neo4j Browser restricts the results (by default, 300 nodes for the graphical results view, and I think 1000 results by table or text result view). So depending on total results, the Neo4j Browser may be running faster because it's not processing and returning all results.