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.

Simple relational query is very slow

I have a simple relational query as below:

 

 

PROFILE MATCH(e:Entity {name:'Mona Lisa'})-[rel]->(e2:Entity) return e,rel,e2

 

 

And the query plan is as below: 

plan.png

"Mona Lisa" entity has 1100 relations in total - 1050 of them to Property nodes, 50 of them to Entity nodes. What I want is only Entities. My database has about 50M nodes and a few billions of relationships. Considering the logic behind Neo4j, the database size should not be important when querying with a start node. This query takes 20 seconds - I'd expect 1 sec. If that's the case why is this query is slow?

Thanks.

1 ACCEPTED SOLUTION

I have different relationship types but they are uncountable (semantic web properties, so a very big number of relationships). 

The reason the query was slow actually is that I have a very big string property in Entity nodes. Returning those for 1k entities takes too much time so I edited the query to return only 'name' of entities and now query finishes in a reasonable time.

PROFILE MATCH(e:Entity {name:'Mona Lisa'})-[rel]->(e2:Entity) return e.name,rel,e2.name

View solution in original post

4 REPLIES 4

@cuneyttyler 

it probably shouldnt matter as it should just work but 

  a.   what version of Neo4j?

  b.   are you running this via the Neo4j Browser, which thus has to render/visualize the results, or via bin/cypher-shell?

 

Neo4j Version is 4.7, running via browser - but as you talked about rendering, I realized that I have a very big values for entities for some searching logic so I returned only names of entities and it's fine now. Thanks.

Do you have different relationship types for each of these two node labels?  If not, you should considered doing so.  You can use the following query, which should be more efficient since the relationships can be filtered by type instead of iterating over every relationship to get the other node and filter on :Entity

match (e:Entity{name:”Mona Lisa”})-[rel:HAS_ENTITY]->(e2) return e, rel, e2

I have different relationship types but they are uncountable (semantic web properties, so a very big number of relationships). 

The reason the query was slow actually is that I have a very big string property in Entity nodes. Returning those for 1k entities takes too much time so I edited the query to return only 'name' of entities and now query finishes in a reasonable time.

PROFILE MATCH(e:Entity {name:'Mona Lisa'})-[rel]->(e2:Entity) return e.name,rel,e2.name