neo4j - How to make this cypher faster? -


this cypher:

start n=node:accounts(account_id={id})  match (n)-[:provider]->(p)<-[r:alert]-()  return r  order {o} asc  skip {s} limit {l} 

following execution plan:

columnfilter(symkeys=["  unnameds239765216", "n", "m", "  unnamed3", "p", "r"], returnitemnames=["r"], _rows=50, _db_hits=0)     slice(skip="{s}", _rows=50, _db_hits=0)       top(orderby=["sortitem(cached(  unnameds239765216 of type any),true)"], limit="add", _rows=50, _db_hits=0)         extract(symkeys=["n", "m", "  unnamed3", "p", "r"], exprkeys=["  unnameds239765216"], _rows=42563, _db_hits=0)           traversalmatcher(trail="(n)-[  unnamed3:provider true , true]->(p)<-[r:alert true , true]-(m)", _rows=42563, _db_hits=614381)             parameterpipe(_rows=1, _db_hits=0) 

accounts have providers (one-many) , providers have incoming alert relations. interested in selecting relations.

first execution takes:

2013-07-18 17:40:54,199 [main] info  net.ahm.graph.dao.alertdao  - >>>> alerts account cypher took: 4789 m-secs 

10th execution of same query takes (engine cached, query parametrized):

2013-07-18 17:41:15,431 [main] info  net.ahm.graph.dao.alertdao  - >>>> alerts account cypher took: 1586 m-secs 

removing order results in following execution plan , time:

2013-07-20 23:45:09,317 [main] debug net.ahm.graph.dao.alertdao  - columnfilter(symkeys=["n", "m", "  unnamed3", "p", "r"], returnitemnames=["r"], _rows=50, _db_hits=0) slice(skip="{s}", limit="{l}", _rows=50, _db_hits=0)   traversalmatcher(trail="(n)-[  unnamed3:provider true , true]->(p)<-[r:alert true , true]-(m)", _rows=50, _db_hits=241)     parameterpipe(_rows=1, _db_hits=0) 2013-07-20 23:45:09,317 [main] info  net.ahm.graph.dao.alertdao  - >>>> alerts account cypher took: 9 m-secs 


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -