0
votes

I have a problem with my cypher query :

start mag=node(1387),f=node(53)
MATCH mag-[:MAGASINS]->t-[:CONTAINS_SF]->sf1-[:IN_FAMILLY]->f
WITH distinct t,f
MATCH t-[:CONTAINS_SF]->sf2-[:IN_FAMILLY]->f1
WITH f,f1,sf2,t
WHERE f<>f1
return sf2,count(distinct t) as count
order by count desc
limit 15

this query takes actually 600ms with just 70k nodes, the target number of nodes is 10M

my jvm args : -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -Xmx5020m
my dev laptop : core i7, ssd, 16go

can you help my for reduce execution time ? Thanks :) Regards Charles.

My neo4j version : 1.9.1 os : mac os 10.8 jdk orcacle 1.7

2

2 Answers

0
votes

try this, so the pattern matcher can pull your f<>f1 comparison into the patern match.

start mag=node(1387),f=node(53)
MATCH mag-[:MAGASINS]->t-[:CONTAINS_SF]->sf1-[:IN_FAMILLY]->f
WITH distinct t,f
MATCH t-[:CONTAINS_SF]->sf2-[:IN_FAMILLY]->f1
WHERE f<>f1
return sf2,count(distinct t) as count
order by count desc
limit 15

what does profiling (profile start ...) your query return ?

  • Is that the first or subsequent runs?
  • make sure to use parameters if you run this in production
0
votes

Have you ever tried indexes some properties? Indexes help optimize the process of finding specific nodes. The command to do this is:

CREATE INDEX ON :Venue(name)

To ensure that all country names are unique, we can add a uniqueness constraint:

CREATE CONSTRAINT ON (c:Country) ASSERT c.name IS UNIQUE