-
Notifications
You must be signed in to change notification settings - Fork 201
Description
We recently started noticing that a lot of our queries are running slowly over bolt from the python driver when they open up new sessions. At first we thought that it was because we were setting up the sessions wrong and so they weren't correctly pulling from the connection pool and it would keep having to start up new connections with each request. However during our debugging and testing we ran into this strange case:
def tf(f):
start = time()
f()
end = time()
return (end - start)*1000
This function is just here to time how long each query takes.
with driver.new_session() as session:
for i in range(0, 500):
val = tf(lambda: session.run("match (n) return count(n)"))
if val > 2:
print i, ":", val
Then this creates one session and uses it to run the same query over and over. Usually the queries take under a ms, but this prints out the ones that didn't and this is what we got:
0 : 3.43799591064
2 : 2.49195098877
6 : 2.96497344971
14 : 4.04977798462
30 : 6.24489784241
62 : 12.0089054108
132 : 23.7801074982
266 : 17.529964447
432 : 41.0959720612
(This was running on my local graph, we see the same thing in our prod environment but with 10x larger slowdowns)
There's a pattern where the one's that take ~10x time is roughly following f(0) = 0, f(n) = f(n-1)+ 2^n
. I've run this a few times and its always the same ones that are slow.
Any ideas what could be going on here and why these specific queries are so slow?