What is the optimal number of specific relationship types to use in Neo4j without negatively impacting performance?

In our Neo4j database, we currently manage around 60 node types and over 200 to 300 relationship variations using a single generic relationship type, -[:RELATES_TO {fieldName: 'relationshipN'}]->. To optimize performance, we're considering replacing this with specific relationship types, potentially creating 250 to 300 distinct relationship types.

Given that Neo4j supports up to 65,535 relationship types, we're wondering:

  • Would using 250+ specific relationship types with millions of data, impact performance during querying?
  • In practical real-world applications, what is generally considered a safe or typical number of relationship types before performance becomes a concern?

Your guidance would be appreciated. Thank you!

Well, if your queries are filtering on your relation property then it should be faster to use specific relationship types, as neo4j doesn’t have to get and evaluate the property. Filtering by node labels and relationship types is fast.

Thanks for your input. But if we add a lot of specific relationship types(e.g. 300 plus or more ), will that adversely affect performance?

@debatosh.tripathy think about it this way: the more "generic", the least performing.

The more filters (labels/types) the smaller the sets where information has to be retrieved and refined.

You also can find that "generic" relationships cause issues.e.g. circular traversals, etc.

2 Likes