The query consumes more than an 30 min to 1.5 hour to load
MG contains around 15000 records
MG_Status around 21k
MATCH (m:MG{MARGIN_PLATFORM: 'ELEC'})-[:DETAILS(TS_END: 7258136400)]- (
ms: MG_Status) with m, ms MATCH (n:MG)
WHERE n.MARGIN_PLATFORM <> 'ZOBA'
with m, n, ms MATCH (n)-[:DETAILS(TS_END: 7258136400)]-(ns: MG_Status)
with m, ms, n, ns
Match p = ((m)-[:RELATED*2..3]-(n)) with m, ms, n, ns, p WHERE all (x IN relationships (p)
WHERE X.TS_END = 7258136400) and ANY (X IN nodes (p)
WHERE X.ACCOUNT_ID = 'CONSOLIDATE')
IS NULL return Distinct ms.MARGIN_GROUP_ID,
ms.MARGIN_PLATFORM, ms.SUB, ms.HOM ns.MARGIN_GROUP_ID, ns.MARGIN_PLATFORM, I
ns.SUB, ns.HOM
What shall be done for optimization to 15 min?