0
votes

Say I have a graph with millions of users, and millions relationships between them. But there is only one relationship of typeX exists in the graph. And at this moment, Neo4j does not support schema index on relationships. Then when I run query:

Match (n)-[r:typeX]->(m) return r;

Does it mean that in order to find this one relationship,
Neo4j has to iterate all the nodes/relationships (in millions) ?

If that is the case, what can be done to improve it? I don't like the idea of introducing extra nodes. First, there are things just naturally should be treated as relations. say 'love', 'hate'. Second, even if extra nodes have been added, queries like (a)-[*..5]->(b) may become much more complex.

1
Is that the complete query? As is, that would return every single relationship of type typeX in your graph.subvertallchris

1 Answers

0
votes

You're right that there are no relationship schema indexes. Typically anything being a "thing" in your domain should be a node. If you're looking for a single global TYPE_X relationship, it looks like being a thing in your domain. You basically have 2 options:

  1. Treat TYPE_X as thing within your domain and make it a node.
  2. use legacy indexes for relationships, see http://docs.neo4j.org/chunked/stable/indexing.html