Hello all,
Below you'll find a snippet of my graph, the query to be performed, it's profile and referenced python script. Most likely there's a problem with the query, but reading the final results from the profile ("Cypher version: CYPHER 3.4, planner: COST, runtime: INTERPRETED. 41608 total db hits in 995 ms.") I would have expected my python script to provide similar 'performance' - it however clocks in at anywhere from 7 to 12 sec's to present the results. The web frontend of Neo shows similar poor performance in presenting the profiled result. How come?
Btw - this is Neo4j 3.4.7 running in a Docker instance started like so
docker run -e NEO4J_dbms_security_procedures_unrestricted=apoc.\*,algo.\* -e NEO4J_dbms_connectors_defaultAdvertisedAddress=x.x.x.x -e NEO4J_dbms_memory_heap_maxSize=8G -v (pwd)/logs:/logs -v (pwd)/data:/data -v (pwd)/plugins:/plugins --user="(id -u):$(id -g)" -p 7474:7474 -p 7687:7687 --ulimit=nofile=40000:40000 neo4j:latest
Python script (neo4j-driver 1.6.2) is running on same server (quad Xeon 6-core, 48GB) as the Docker container
Graph
Query
profile match (n:Document)<-[:HAS_DOCUMENT]-(f:Functional_Location)-[:HAS_TAG]->(h:HistoryTag)
where n.name='xxx' and exists(h.has_state)
match (h)-[:IN_STATEPERIOD]->(s:StatePeriod)-[:HAS_DATASTATE]->(d:DataState)
where s.from=DateTime('xxx')
return h.name, s.from, s.to, d.from, d.to, d.h, d.class, d.pct, d.angle, d.numpoints, d.last, d.a, d.b, d.c
n.name, h.has_state and s.from are all indexed
Profile part 1
Profile part 2
Python script
from neo4j.v1 import GraphDatabase, basic_auth
uri = "bolt://x.x.x.x:7687"
auth_token = basic_auth("xxx", "xxx")
driver = GraphDatabase.driver(uri, auth=auth_token)
def getData():
session=driver.session()
result=session.run(
"match (n:Document)<-[:HAS_DOCUMENT]-(f:Functional_Location)-[:HAS_TAG]->(h:HistoryTag) "
"where n.name={doc} and exists(h.has_state) "
"with collect(h) as tags unwind tags as h "
"match (h)-[:IN_STATEPERIOD]->(s:StatePeriod)-[:HAS_DATASTATE]->(d:DataState) "
"where s.from=DateTime({time}) "
"return h.name, s.from, s.to, d.from, d.to, d.h, d.class, d.pct, d.angle, d.numpoints, d.last, d.a, d.b, d.c",
{'doc':'xxx', 'time':'xxx'}
)
session.close()
for x in result:
print x['h.name'], '\n\n'
if __name__=='__main__':
getData()