cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

APOC/cypher use

newkid
Node Clone

Apologies if this has been answered as I have searched but don't have a clear understanding.

  1. When is it better to use cypher over apoc and vice-versa?
  2. What cannot be done using one or the other?
  3. Are there any specific examples of types of cypher/apoc queries compared to see performance differences?

I have used cypher for loading data, creating/merging nodes and querying, used apoc for relationships, import/export but I am always interested in learning new techniques.

Thanks in advance.

1 REPLY 1

APOC in general is there to fill some gaps in functionality in Cypher, but some features in Cypher have caught up over the years.

One prime example is apoc.periodic.iterate() for batching changes from streamed input, which could be from a Cypher query of the graph itself. Cypher didn't have a good answer for that until 4.4.x, when we introduced subqueries for transaction batching:

APOC path expansion procedures (such as apoc.path.subgraphNodes()) can be useful for some cases that aren't yet well supported in Cypher, such as expansion to distinct nodes in a graph. The path expanders have a way to prune paths when you reach a node that has already been visited, that can keep down the number of distinct found paths needing further processing, and cutting out that work can improve performance. The path expanders can also handle repeating sequences during expansion, something that is not yet possible (but actually not too far off) in Cypher.

APOC helper functions (for coll, map, convert, agg, and others) are awesome, providing some great utility at a very fine level. The converting to/from JSON strings is a strong highlight here. These alone can justify using APOC, and eventually some of these make their way into Cypher proper.

Connection procedures, for example loading via JDBC or other connectors, can also be very useful when you're pulling from different data sources.

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online