Query takes too long time

Hi,
Let’s say i have nodes A->B->C and i want to select B nodes with no a_b and b_c edges

I do this:

 {
    var(func: has(B)) {
      id as uid
      cnta as count(~a_b)
      cntc as count(b_c)
   }
   q(func: uid(id)) @filter(eq(val(cnta),0) and eq(val(cntc),0)) {
      uid
   } 
}

The query takes for about 11s when set of B is 87000 nodes(too long)
The same query in neo4j (match(b:B) where not (b)--() return b ) takes for about 500ms only

What is the proper way for the query ?

Thanks

Why are you using these filters?

I guess this work as intended.

{
    var(func: has(B)) {
      id as uid
      cnta as ~a_b
      cntc as b_c
   }
   q(func: uid(id, cnta, cntc))  {
      uid
   } 
}

Hi Michael,

Your query gives wrong result. I want to get those of B nodes which do not have edges with A and C. My query gives right result but takes too long time.

did you try this one?

{
a as var(func: has(~a_b))

c as var(func: has(b_c))

b(func: has(B)) @filter(not(uid(a)) and not(uid(c))) {
  uid
}
}

Thank you, Nikita.
Your query returns result in 369ms

or even simplier:

{
b(func: has(B)) @filter(not(has(~a_b)) and not(has(b_c))) { uid }
}

And this query returns result in 6,7s(not good)

ok then:)
seems like second query is filtering 1 by 1, whereas first one is loading all predicates at once. thats the case

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.