hi team, here below is my query for resolving the profiles which are similar, this query works perfect when we run it on 4-5 customers
But while running this on 3,85,000 customers is giving timeout (we set the restpp timeout of 1200 seconds)
- Any way to optimize this logic ?
- if somehow, we want to consider customer attributes too (“date_of_birth” | “first_name” too, with the weightage of:-
date_of_birth : 0.2
first_name: 0.2
then how can we achieve this in our logic ?
CREATE DISTRIBUTED QUERY test(float threshold = 0.6) FOR GRAPH clientC_retail syntax V2{
/* Write query logic here */
//start = {Profile.*};
MapAccum<STRING, SetAccum<STRING>> @@id_list;
SetAccum<EDGE> @@edges;
MapAccum<STRING, FLOAT> @@same_profiles;
SumAccum<float> @score;
start = {AM_CUSTOMER.*};
all_profiles = {AM_CUSTOMER.*};
proxy_profiles = SELECT s FROM start:s-((customer_email|customer_contact|customer_address):e)-:t-((customer_email|customer_contact|customer_address):ee)-AM_CUSTOMER:tt
where s.account_no!=tt.account_no accum
IF s.account_no!=tt.account_no THEN
@@id_list += (s.account_no->tt.account_no)
END;
#print @@id_list;
FOREACH (root_customer,childs) IN @@id_list DO
related_profiles = select s from all_profiles:s where s.account_no in childs;
related_profiles = SELECT s
FROM related_profiles:s-((customer_email|customer_contact|customer_address):e)-:t-((customer_email|customer_contact|customer_address):ee)-AM_CUSTOMER:tt
where s!=tt AND tt.account_no!="0"
ACCUM CASE ee.type
WHEN "customer_email" THEN @@same_profiles += (tt.account_no->0.6)
WHEN "customer_contact" THEN @@same_profiles += (tt.account_no->0.6)
WHEN "customer_address" THEN @@same_profiles += (tt.account_no->0.3)
#WHEN "profile_address" THEN s.@same_profiles += (tt->0.1)
#WHEN "profile_device" THEN s.@same_profiles += (tt->0.5)
end;
#PRINT related_profiles;
#PRINT @@same_profiles.get(root_customer);
#PRINT @@same_profiles.get(root_customer) >= threshold;
related_profiles = select s from related_profiles:s
POST-ACCUM
if @@same_profiles.get(root_customer) >= threshold then
insert into same_customer values(root_customer, s, @@same_profiles.get(root_customer))
end;
END;
}
Please guide
Thanks