Edge filter based query taking a long time to evaluate


(Himanshu Barthwal) #1

I have a query for getting all german listings of US issuers as follows:

{
  german_listings_for_us_issuers(func: has(isIssuerOf)) @filter(eq(region, "US")) @normalize {
    isIssuerOf {
      listsIn @filter(eq(region, "DE")) {
        entity_id : entity_id
      }
    }
  }
}

Here is the schema for isIssuerOf

<isIssuerOf>: uid @reverse .

The above query takes more than 30 seconds to come back with results. However, if I change that has clause to use Entity.PVT (a predicate that I have added as per the recommendation here) then it takes 5-10 seconds to evaluate despite the fact that there are 10 times more nodes that match this predicate. Am I doing something wrong here? How do we typically filter nodes based on the edges?


(Michel Conrado) #2

I would recommend you to use eq in root and facet in the nested blocks.

{
  german_listings_for_us_issuers(func: eq(region, "US") )
   @filter(has(isIssuerOf)) @normalize {
    isIssuerOf {
      listsIn @facets(eq(region, "DE")) {
        entity_id : entity_id
      }
    }
  }
}

As facets are not first-class citizen. They don’t use a lot of resource, so they can perform better. If you need it so.