match (m:`USER`) where id(m) in ["1510615318"]
optional match (m)-[r1:CALL_TO]-(x:MOBILE)-[:APPLY_FOR]->(a1:APPL)-[:APPLY_ON]-(t1:`TIME`)
where r1.first_callmark_on<=20220102 and t1.`TIME`.`date` < '2022-01-02'
with m,collect(distinct x) as col_appl_1st_v4
unwind case when size(col_appl_1st_v4) == 0 then [null] else col_appl_1st_v4 end as x
match (x)-[r2:CALL_TO]-(n:`USER`)
where r2.first_callmark_on<=20220102 and id(n)<>'1510615318'
with m,col_appl_1st_v4,collect(distinct n) as col_user_2nd_v4
with m,col_appl_1st_v4,col_user_2nd_v4, [uu in col_user_2nd_v4 WHERE "MOBILE" in labels(n)] as col_mobile_2nd_v4
return size(col_appl_1st_v4) as n_appl_1st_v4, size(col_user_2nd_v4) as n_user_2nd_v4
这个语句是最开始的写法,并且会 OOM。
match (m:USER) where id(m) in [“1510615318”]
optional match (m)-[r1:CALL_TO]-(x:MOBILE)-[:APPLY_FOR]->(:APPL)-[:APPLY_ON]-(t1:TIME)
where r1.first_callmark_on<=20220102 and t1.TIME.date < ‘2022-01-02’
optional match (x)-[r2:CALL_TO]-(n:USER)
where r2.first_callmark_on<=20220102 and id(n)<>‘1510615318’
with m, collect(distinct x) as col_appl_1st_v4, collect(distinct n) as col_user_2nd_v4
with m, col_appl_1st_v4, col_user_2nd_v4, n_cbkin_State_enterprise_leader_2nd_v4,[uu in col_user_2nd_v4 WHERE “MOBILE” in labels(uu)] as col_mobile_2nd_v4
return size(col_appl_1st_v4) as n_appl_1st_v4, size(col_user_2nd_v4) as n_user_2nd_v4
从这里开始照之前那种改写 就会oomunwind case when col_mobile_2nd_v4 =[] then [null] else col_mobile_2nd_v4 end as n optional match (n:MOBILE)-[:APPLY_FOR]->(a2:APPL)-[:APPLY_ON]->(t2:TIME) where replace(t2.date,'-','')<='20220602' with m,col_appl_1st_v4,col_user_2nd_v4,col_mobile_2nd_v4,n_cbkin_State_enterprise_leader_2nd_v4,n_cbkin_Engineer_2nd_v4, collect(distinct case when a2 is not null then n else null end) as col_appl_2nd_v4
match (m:`USER`) where id(m) in ["1510615318"]
optional match (m)-[r1:CALL_TO]-(x:MOBILE)-[:APPLY_FOR]->(:APPL)-[:APPLY_ON]-(t1:`TIME`)
where r1.first_callmark_on<=20220102 and t1.`TIME`.`date` < '2022-01-02'
optional match (x)-[r2:CALL_TO]-(n:`USER`)
where r2.first_callmark_on<=20220102 and id(n)<>'1510615318'
optional match (n)<-[r3:CBK_STATE_ENTERPRISE_LEADER]-(n2:`USER`)
where r3.first_cbkmark_on<=20220602 and id(n2)<>'1510615318'
optional match (n2)<-[r4:CBK_ENGINEER]-(n3:`USER`)
where r4.first_cbkmark_on<=20220602 and id(n3)<>'1510615318'
optional match (n4:MOBILE)-[:APPLY_FOR]->(a2:APPL)-[:APPLY_ON]->(t2:TIME)
where t2.`TIME`.`date` < '2022-01-02'
with
m,
collect(distinct x) as col_appl_1st_v4,
collect(distinct n) as col_user_2nd_v4,
count(distinct n2) as n_cbkin_State_enterprise_leader_2nd_v4,
count(distinct case when n2 is not null then n3 else null end) as n_cbkin_Engineer_2nd_v4
count(distinct case when n4 is not null then n3 else null end) as col_appl_2nd_v4
with
m,
col_appl_1st_v4,
col_user_2nd_v4,
n_cbkin_State_enterprise_leader_2nd_v4,
[uu in col_user_2nd_v4 WHERE "MOBILE" in labels(uu)] as col_mobile_2nd_v4,
n_cbkin_Engineer_2nd_v4,
col_appl_2nd_v4
return
size(col_appl_1st_v4) as n_appl_1st_v4,
size(col_user_2nd_v4) as n_user_2nd_v4,
size(col_mobile_2nd_v4) as n_mobile_2nd_v4,
n_cbkin_State_enterprise_leader_2nd_v4,
n_cbkin_Engineer_2nd_v4,
col_appl_2nd_v4
match (m:`USER`) where id(m) in ["1510615318"]
optional match (m)-[r1:CALL_TO]-(x:MOBILE)-[:APPLY_FOR]->(:APPL)-[:APPLY_ON]-(t1:`TIME`)
where r1.first_callmark_on<=20220102 and t1.`TIME`.`date` < '2022-01-02'
optional match (x)-[r2:CALL_TO]-(n:`USER`)
where r2.first_callmark_on<=20220102 and id(n)<>'1510615318'
optional match (n)<-[r3:CBK_STATE_ENTERPRISE_LEADER]-(n2:`USER`)
where r3.first_cbkmark_on<=20220602 and id(n2)<>'1510615318'
optional match (n2)<-[r4:CBK_ENGINEER]-(n3:`USER`)
where r4.first_cbkmark_on<=20220602 and id(n3)<>'1510615318'
with m, collect(distinct x) as col_appl_1st_v4, collect(distinct n) as col_user_2nd_v4,count(distinct n2) as n_cbkin_State_enterprise_leader_2nd_v4,count(distinct case when n2 is not null then n3 else null end) as n_cbkin_Engineer_2nd_v4
unwind col_user_2nd_v4 as n4
optional match (n4:MOBILE)-[:APPLY_FOR]->(a2:APPL)-[:APPLY_ON]->(t2:TIME)
where t2.`TIME`.`date` < '2022-01-02'
RETURN m,col_appl_1st_v4,col_user_2nd_v4,n_cbkin_State_enterprise_leader_2nd_v4,n_cbkin_Engineer_2nd_v4,count(distinct case when n4 is not null then n3 else null end) as col_appl_2nd_v4
match (m:`USER`) where id(m) in ["1510615318"]
optional match (m)-[r1:CALL_TO]-(x:MOBILE)-[:APPLY_FOR]->(:APPL)-[:APPLY_ON]-(t1:`TIME`)
where r1.first_callmark_on<=20220102 and t1.`TIME`.`date` < '2022-01-02'
optional match (x)-[r2:CALL_TO]-(n:`USER`)
where r2.first_callmark_on<=20220102 and id(n)<>'1510615318'
optional match (n)<-[r3:CBK_STATE_ENTERPRISE_LEADER]-(n2:`USER`)
where r3.first_cbkmark_on<=20220602 and id(n2)<>'1510615318'
optional match (n2)<-[r4:CBK_ENGINEER]-(n3:`USER`)
where r4.first_cbkmark_on<=20220602 and id(n3)<>'1510615318'
with
m,
collect(distinct x) as col_appl_1st_v4,
collect(distinct n) as col_user_2nd_v4,
count(distinct n2) as n_cbkin_State_enterprise_leader_2nd_v4,
count(distinct case when n2 is not null then n3 else null end) as n_cbkin_Engineer_2nd_v4
unwind col_user_2nd_v4 as n4
optional match (n4:MOBILE)-[:APPLY_FOR]->(a2:APPL)-[:APPLY_ON]->(t2:TIME)
where t2.`TIME`.`date` < '2022-01-02'
RETURN
m,
col_appl_1st_v4,
col_user_2nd_v4,
n_cbkin_State_enterprise_leader_2nd_v4,
n_cbkin_Engineer_2nd_v4,
count(distinct case when n4 is not null then n3 else null end) as col_appl_2nd_v4
match (m:USER {mobileId:'1bb7d145a19749a9e1b1f12dc613233115d5df3e22c741309ea12e71256d03d6'})
optional match (m)-[r1:CALL_TO]-(x:MOBILE)-[:APPLY_FOR]->(a1:APPL)-[:APPLY_ON]-(t1:TIME)
where r1.first_callmark_on<=20220602 and t1.`TIME`.`date`<='2022-06-02'
optional match (x)-[r2:CALL_TO]-(n:USER)
where r2.first_callmark_on<=20220602 and id(m)!=id(n)
optional match (n:MOBILE)<-[r3:CBK_STATE_ENTERPRISE_LEADER]-(y1:USER)
where r3.first_cbkmark_on<=20220602 and id(y1)!=id(n)
optional match (n:MOBILE)<-[r4:CBK_ENGINEER]-(y2:USER)
where r4.first_cbkmark_on<=20220602 and id(y2)!=id(n)
optional match (n:MOBILE)-[:APPLY_FOR]->(a2:APPL)-[:APPLY_ON]->(t2:TIME)
where t2.`TIME`.`date`<='2022-06-02'
optional match (n:MOBILE)-[:APPLY_FOR]->(a3:LOAN_BK)-[:APPLY_ON]->(t3:TIME)
where t3.`TIME`.`date`<='2022-06-02'
optional match (n:MOBILE)-[:APPLY_FOR]->(a4:LOAN_BK)-[:M2_ON]->(t4:TIME)
where t4.`TIME`.`date`<='2022-06-02'
optional match (n:MOBILE)-[:APPLY_FOR]->(a5:A_BLACK_LIST)-[:APPLY_ON]->(t5:TIME)
where t5.`TIME`.`date`<='2022-06-02'
optional match (n:MOBILE)-[:APPLY_FOR]->(a6:C_BLACK_LIST)-[:APPLY_ON]->(t6:TIME)
where t6.`TIME`.`date`<='2022-06-02'
return
count(distinct x) as n_appl_1st_v4,
count(distinct n) as n_user_2nd_v4,
count(case when "MOBILE" in labels(n) then n else null end) as n_mobile_2nd_v4,
count(distinct a2) as n_appl_2nd_v4,
count(distinct y1) AS n_cbkin_State_enterprise_leader_2nd_v4,
count(distinct y2) AS n_cbkin_Engineer_2nd_v4,
count(distinct a3) as n_bk_2nd_v4,
count(distinct a4) AS n_bad30p_2nd_v4,
count(distinct a5) AS n_ablk_2nd_v4,
count(distinct a6) AS n_cblk_2nd_v4,
count(case when 'ORG' in labels(n) then n else null end) as n_org_2nd_v4,
count(case when 'EXPRESS' in labels(n) then n else null end) as n_express_2nd_v4,
count(case when 'AGENCY' in labels(n) then n else null end) as n_agency_2nd_v4,
count(case when 'BNK_ORG' in labels(n) then n else null end) as n_bnk_org_2nd_v4,
count(case when 'OTHER_ORG' in labels(n) then n else null end) as n_other_org_2nd_v4
match (m:`USER`) where id(m) in ["1510615318"]
optional match (m)-[r1:CALL_TO]-(x:MOBILE)-[:APPLY_FOR]->(a1:APPL)-[:APPLY_ON]-(t1:`TIME`)
where r1.first_callmark_on<=20220602 and t1.`TIME`.`date`<='2022-06-02'
optional match (x)-[r2:CALL_TO]-(n:`USER`)
where r2.first_callmark_on<=20220602 and id(m)!=id(n)
return m
match (m:`USER`) where id(m) in ["1510615318"]
optional match (m)-[r1:CALL_TO]-(x:MOBILE)-[:APPLY_FOR]->(a1:APPL)-[:APPLY_ON]-(t1:`TIME`)
where r1.first_callmark_on<=20220602 and t1.`TIME`.`date`<='2022-06-02'
optional match (x)-[r2:CALL_TO]-(n:`USER`)
where r2.first_callmark_on<=20220602 and id(n)<>'1510615318'
optional match (n:MOBILE)<-[r3:CBK_STATE_ENTERPRISE_LEADER]-(y1:`USER`)
where r3.first_cbkmark_on<=20220602 and id(n)<>'1510615318'
optional match (n:MOBILE)<-[r4:CBK_ENGINEER]-(y2:`USER`)
where r4.first_cbkmark_on<=20220602 and id(n)<>'1510615318'
optional match (n:MOBILE)-[:APPLY_FOR]->(a2:APPL)-[:APPLY_ON]->(t2:`TIME`)
where t2.`TIME`.`date`<='2022-06-02'
optional match (n:MOBILE)-[:APPLY_FOR]->(a3:LOAN_BK)-[:APPLY_ON]->(t3:`TIME`)
where t3.`TIME`.`date`<='2022-06-02'
optional match (n:MOBILE)-[:APPLY_FOR]->(a4:LOAN_BK)-[:M2_ON]->(t4:`TIME`)
where t4.`TIME`.`date`<='2022-06-02'
optional match (n:MOBILE)-[:APPLY_FOR]->(a5:A_BLACK_LIST)-[:APPLY_ON]->(t5:`TIME`)
where t5.`TIME`.`date`<='2022-06-02'
optional match (n:MOBILE)-[:APPLY_FOR]->(a6:C_BLACK_LIST)-[:APPLY_ON]->(t6:`TIME`)
where t6.`TIME`.`date`<='2022-06-02'
return
count(distinct x) as n_appl_1st_v4,
count(distinct n) as n_user_2nd_v4,
count(case when "MOBILE" in labels(n) then n else null end) as n_mobile_2nd_v4,
count(distinct a2) as n_appl_2nd_v4,
count(distinct y1) AS n_cbkin_State_enterprise_leader_2nd_v4,
count(distinct y2) AS n_cbkin_Engineer_2nd_v4,
count(distinct a3) as n_bk_2nd_v4,
count(distinct a4) AS n_bad30p_2nd_v4,
count(distinct a5) AS n_ablk_2nd_v4,
count(distinct a6) AS n_cblk_2nd_v4,
count(case when 'ORG' in labels(n) then n else null end) as n_org_2nd_v4,
count(case when 'EXPRESS' in labels(n) then n else null end) as n_express_2nd_v4,
count(case when 'AGENCY' in labels(n) then n else null end) as n_agency_2nd_v4,
count(case when 'BNK_ORG' in labels(n) then n else null end) as n_bnk_org_2nd_v4,
count(case when 'OTHER_ORG' in labels(n) then n else null end) as n_other_org_2nd_v4