ac-lap
ac-lap

Reputation: 1653

First neo4j query taking more than expected time

I have an API in Django and its structure is something like -

FetchData():
  run cypher query1
  run cypher query2
  run cypher query3
  return

When I run these queries in neo4j query window each take around 100ms. But when I call this API, query1 takes 1s and other 2 take expected 100ms to execute. This pattern is repeated every time I call the API.

Can anyone explain what should be done here to run the first query in expected time.

Upvotes: 0

Views: 101

Answers (2)

David Fox
David Fox

Reputation: 116

That sounds weird. The cache should only need to be warmed if the server or db is shut down, not after each of your API calls. Are you using paramterized queries? The only thing I can think of is maybe each set of queries is different causing them to have to be re-parsed and re-planned.

Upvotes: 0

Stefan Armbruster
Stefan Armbruster

Reputation: 39926

Neo4j tries to cache the graph in RAM. Upon first invocations caches are not warmed up yet, so it takes longer to do the IO operations. Subsequent invocations don't hit IO and read directly from RAM.

Upvotes: 1

Related Questions