Hi Team,
We have successfully implemented Apoc procedure to replace views. But now we are facing performance issues while using apoc procedures in our cypher queries.
Let me detail out the implementation
I have created one Apoc procedure path_element_v with one imput parameter (path_type) , this apoc procedure returns all path details of this path type passing as input.
now we are using this apoc procedure in another Apoc procedure using apoc.cypher.run and execute it for each path name as below
call apoc.custom.asProcedure('RIL_OCH_PATH_TERMINATION_V','match (a:inventoryObjects{type : $param})-[r:INSTANCE_OF]->(c:classes{name:'gPath'})
with a
optional match (b:inventoryObjects{site_inst_id : a.a_side_site_id})-[r:INSTANCE_OF]->(c:classes{name : 'gFacility'})
with a,b
optional match (d:inventoryObjects{site_inst_id : a.z_side_site_id})-[r:INSTANCE_OF]->(c:classes{name : 'gFacility'})
with a,b,d
CALL apoc.cypher.run(
"call custom.path_element_v('gPath') yield path_element_parent_equip as path_element_parent_equip,
path_element_port as path_element_port,path_pkey as path_pkey,path_element_no as path_element_no
where path_pkey = "+ a.circ_path_inst_id +"
AND path_element_port is not null
RETURN path_element_parent_equip as path_a_equip_slte,path_element_port as path_a_port
ORDER BY path_element_no ASC
LIMIT 1",{}
) yield value
return a.name AS path_name,
a.type AS path_type,
a.status AS path_status,
a.bandwidth AS path_bandwidth,
b.name AS path_aside_site,
d.name AS path_zside_site,
value.path_a_equip_slte as path_a_equip_slte',
'read',[['path_name','String'],['path_type','String'],['path_status','String'],['path_bandwidth','String'],['path_aside_site','String'],
['path_zside_site','String'],['path_a_equip_slte','String']],[['param','String']],'OCh Path Termination');
the entire execution takes more than 20 mins. I ran the profile on statement
call custom.path_element_v('gPath') yield path_element_parent_equip as path_element_parent_equip,
path_element_port as path_element_port,path_pkey as path_pkey,path_element_no as path_element_no
where path_pkey = 3065 -- To hardcode the value to see the plan
AND path_element_port is not null
RETURN path_element_parent_equip as path_a_equip_slte,path_element_port as path_a_port
ORDER BY path_element_no ASC
LIMIT 1
and find the output in attached file

We need expert advise to optimize this solution .