Some question about @recurse

i had tested these two query

first one
{
  result(func: eq(entityName,"aaa")) {
    uid
    entityName
    creditCode
    ~invest {
      uid
      entityName
      creditCode
      ~invest{
        uid
        entityName
        creditCode
        ~invest{
          uid
          entityName
          creditCode
           ~invest{
            uid
            entityName
            creditCode
             ~invest{
              uid
              entityName
              creditCode
             }
    			 }
 			  }
    	}
    }
  }
}

and the second one ,a @recurse query

{
  result(func: eq(entityName,"aaa")) @recurse(depth: 5, loop: true){
    uid
    entityName
    creditCode
    ~invest 
}
}

they return same result,but the first one is way faster than @recurse query,first one cost 98 ms,second one cost 6286.89 ms, can anybody tell me why this happen,thanks

1 Like

That’s a good question. It should be the same in theory oO

@Anurag are you able to check this?

1 Like

@Anurag can you check this please?

1 Like

I’m not quite sure but since you are using reverse edges could loop: true be the problem? Have you tried setting it to false?

But yes, I’ve also experienced that @recurse slows down queries, see here