0

i am using neo4j community version , i am having 1 node of "City" , and approx 5000 nodes of "BusinessDetails" connected with realtion "CONTAINS" from "City" to "BusinessDetails" , when 1 am using the cypher query

MATCH (n:City{name : "hyderabad"})-[:CONTAINS]->(p:BusinessDetails) return p

it is taking approx 8 seconds to fetch the results. How to optimize this ? and why it is taking so much of time? i am really new with neo4j.

aditya mathur
  • 75
  • 1
  • 2
  • 6
  • Please confirm that your DB contains only one `City` node, as your question states. Does this query return 1: `MATCH (n:City) RETURN COUNT *`. – cybersam Dec 22 '15 at 21:21

1 Answers1

1

First of all make sure you've added index on the City name

CREATE INDEX ON :City(name)

Next always Match the filtering in a separate match statement

MATCH (n:City{name : "hyderabad"})
MATCH n-[:CONTAINS]->(p:BusinessDetails)
RETURN p

This will enhance your performance a bit. Anyway this can be a configuration problem or hardware as you are talking about very small numbers compared to what I'm using and still I'm having better performance.

khaled_gomaa
  • 3,382
  • 21
  • 24