how to speed up the search for matching nodes?

14 views
Skip to first unread message

kincheong lau

unread,
Jul 13, 2016, 11:27:47 PM7/13/16
to Neo4j
I need a way to speed up my query, not sure if this is the right way but this is how I did it and very slow:

1. identify Anonymous-Users with last actions on 18 May

MATCH (u:Anonymous-Users)-[r:INQUIRY_ON|VIEW]->(p:Product)-[:BELONG_TO]->(l4:Category)
with u as u, head(collect(r.traffic_ts)) as headts, head(collect(p.id)) as headp, head(collect(l4)) as headl4 order by u.cookie
WHERE (headts > 1463500800000  and headts < 1463587200000) // this is millisecond time
return u.cookie, headp, headl4 order by u.cookie;

there are 4,000,000 Anonymous-Users in DB so running this first cypher has taken like 20 mins to return 32,898 rows

2. after identifying Anonymous-Users cookie the goal is to return User details who are Registered-Users, below is the extended version:


MATCH (u:Anonymous-Users)-[r:INQUIRY_ON|VIEW]->(p:Product)-[:BELONG_TO]->(l4:Category)
with u as u, head(collect(r.traffic_ts)) as headts, head(collect(p.id)) as headp, head(collect(l4)) as headl4 order by u.cookie
WHERE (headts > 1463500800000  and headts < 1463587200000) // this is millisecond time
with u.cookie as ucookie, headp as headp, headl4 as headl4 order by u.cookie
match (b:Registered-Users)
where has(b.nvu_cookie_id) and b.nvu_cookie_id = ucookie
return b.id, b.desc;

we have 600,000 Registered Buyer, and this cypher is running forever and never return

I believe there's a smarter way doing this?
Reply all
Reply to author
Forward
0 new messages