i have simple apoc.periodic.iterate query , which when i am executing on neo4j desktop it is running in 6ms but when i am trying to hit the same query from api written in python , it is taking infinite time.
how do i hit the query -
- in my api functions i first create a graphdb session
- then using write_transaction function , create a transaction
- now create the query as string , and executing the query through transaction.run(query)
now as my query comes to transaction.run(query) it is not responding.
Called this function through session.write_transaction and also paased the transaction tx
query = []
while tier_length > 1:
for day in range(1,21):
net_req_and_closing_stock_query_1 = """'match (n:vc:commonlabelindex)
where n.tier = {tier} and n.date = date("2022-11-{day}")
with n,(n.net_req)-(n.opening_inventory + n.incoming_stock) as x
return n,x'"""
net_req_and_closing_stock_query_2 ="""'set n.net_req_updated = case
when x > 0 then x
else 0 end,
n.closing_stock = case
when x < 0 then -x
else 0 end'"""
net_req_and_closing_stock_query_1 = net_req_and_closing_stock_query_1.format(tier = tier_length ,day = day)
base_query = '''call apoc.periodic.iterate({query_1},{query_2},{settings})'''
settings = '{batchSize:1000,iterateList:true,parallel:false}'
base_query = base_query.format(query_1 = net_req_and_closing_stock_query_1,
query_2 = net_req_and_closing_stock_query_2,
settings = settings)
query.append(base_query)
ExecuteQueries.execute_set_queries(tx, query, "requirement calculation for vc")
then
def execute_set_queries(tx, execute_queries, type):
try:
start = datetime.datetime.now()
for query in execute_queries:
res = tx.run(query)
result = {"time": (datetime.datetime.now() - start)/1000, "type": type}
# print("result is ::::",result)
return result
here in tx.run it is getting stuck