The friend-of-friend example is the most famous argument in favor of Neo4j when talking about performance. Since Neo4j is known to be incredibly performant at traversing relationships, contrary to other Database engines, we expect the response time of this query to be quite low.
Neo4j Browser displays the query execution time in the result cell:
It can also be measured programmatically. For instance, using the Neo4j Python driver from the Neo4j package, we can measure the total execution and streaming time with the following:
from neo4j import GraphDatabase
URL = "bolt://localhost:7687"
USER = "neo4j"
PWD = "neo4j"
driver = GraphDatabase.driver(URL, auth=(USER, PWD)
query = "MATCH (a:Person {id: 203749})-[:IS_FRIEND_WITH]-(b:Person) RETURN count(b.id)"
with driver.session() as session:
with session.begin_transaction() as tx:
result = tx.run(query)
summary = result.summary()
avail = summary.result_available_after...