Neography: Traversal vs. Cypher

1.3k views Asked by At

Im currently building something with Neo4j and Neography and were wondering what is preferred: Using the traverse method or a Cypher query?

Personally, I like Cypher, but I have no idea which is better/more performant

3

There are 3 answers

0
nambrot On BEST ANSWER

Cypher is indeed intuitive as Matthias pointed out, however I have the following recommendation:

If its trivial stuff, go Cypher, its easier to write (actually a joy) and there shouldn't be any big performance penalty. However, once you have larger matchings or conditional queries, having domain knowledge of your graph might significantly boost performance if you use custom traversers or even Gremlin

0
Mattias Finné On

I'm sure they both have their sweet spots, and Cypher probably already being more intuitive to express your queries in. Try forming your queries with Cypher if that is to your liking and if the performance satisfies you then all good! If not then perhaps try it out in the traversal framework.

0
Rene Pickhardt On

I have just created a benchmark for friend of a friend queries for Cypher vs Core API and the Traverser Framework on a graph with about 1 mio nodes. FOAF queries are not very complex but a good use case for graph data bases like neo4j.

http://www.rene-pickhardt.de/get-the-full-neo4j-power-by-using-the-core-java-api-for-traversing-your-graph-data-base-instead-of-cypher-query-language/

Cypher performs slower by at least one order of magnitude

You can see that Cypher performs much worse than the core API.