Filter question


(Orlando) #1

As far as I know any inequality filter requires an Index even if not used in the query root, that means that even if the query root just gives one result the filters will look the index table for all the inequality filters.

These can be bypassed if the filters are applied in facets, so my question is: performance wise, If I would never use the edges to filter on query root, would it be better to filter on facets to avoid the indexing or it’s recommended to use the index better (the increase of the storage for the index table is not a problem, just want to know which approach is better and more scalable)?

Data Example

{
     "uid":         "_:group",
     "group":       "",
     "group_Name":  "demo",
     "hasEvent": {
            "uid":              "_:event ",
            "event":            "",
            "event_name":       "demo event",
            "starts":           234455656657 //timestamp, indexed
            "hasEvent|starts":  234455656657 //facet not indexed
      }
}

Query using Index

{
test(func: uid(:_group)){
   group_name
   hasEvent @filter(eq(starts,234455656657)){
        uid
        event_name
   }
}
}

Query using Facets not indexing required

{
test(func: uid(:_group)){
   group_name
   hasEvent @facets(eq(starts,234455656657)){
        uid
        event_name
   }
}
}

(Michel Conrado) #2

Facets in some cases are better, I think for this approach is totally acceptable. Keeping in mind that Facets are not First-class-citizen.