简体   繁体   中英

In Neo4j v4.0, Graph Data Science Library: why is Native Projection better than Cypher Projection in terms of performance?

The documentation Creating graphs in the catalog claims such performance advantange when using Native Projection over Cypher Projection, but does not give much explanation.

Native projection
Provides the best performance...

Cypher projection
The more flexible, expressive approach with lesser focus on performance.

As I understand, all projections will end up:

Graph projections are stored entirely in-memory using compressed data structures optimized for topology and property lookup operations.

So why is the performance gain?

In addition, the assumed gained performance is for loading (materialize) the projected graph or later for processing, eg with PageRank algorithm?

You are correct, all projections end up stored entirely in-memory. The difference between cypher projection and native projection is how fast we can store or materialize the projected graph. As far as I know, native projection uses internal Neo4j API, which makes it faster to load the graph, but is limited to only specifying node labels and relationship types. Cypher projection, on the other hand, supports all the features of cypher and can be used to filter the subgraph we want to project very flexibly. We can also project a virtual graph. A very common projection of a virtual graph is to project a bipartite graph as a unipartite graph using only cypher projection. You must realize though that the more complex your cypher queries are, the slower the graph projection will be. And even just projecting a single node label and relationship type will be slower with cypher projection than with native projection. But I wouldn't worry much about that until your graph gets bigger than 10s of millions of nodes and relationships

Once the graph is materialized in-memory, the execution times of the algorithms should be the same regardless of the algorithm being projected with cypher projection or native projection.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM