every eq operation performs lookups to index both for func
and filter
cases.
to have good performance in dgraph, you should use predicates for types, areas and so on.
so, instead of space.name
predicate with “dev” value you should create empty space.name.dev
predicate with “” value for each log in this space. the same for log.type
- replace it with log.type.LOG
with “” value. you don’t need indexes for these predicates.
if you want to calculate logs for days interval, create a node for each day and link every log node to this day node with log.day
predicate.
if you want to count all logs for day interval, firstly you get all day nodes, then all linked to that day nodes logs (via reverse predicate).
so, your query will be like:
var(func: ge(day.date, "2018-12-01")) {
logs as ~log.day
}
request(func: uid(logs)) @filter(has(space.name.dev) and has(log.type.LOG)) {
count(uid)
}
or even just:
request(func: ge(day.date, "2018-12-01")) {
~log.day @filter(has(space.name.dev) and has(log.type.LOG)) {
count(uid)
}
}
it should work fast.
but why are you using graph db for that? why not ElasticSearch?