Hello, developers.
we have a problem. we run such a query
{
mfLjOe(func: type(A)) @filter(eq(field1, "value1")){
b as ~A
}
nCVefd(func: uid(b)) {
B @filter(type(B) AND eq(field2, "value2")) {
c as ~B
}
}
end(func: uid(c)) {
count(uid)
}
}
What I did
when data rise to exceed 100 million, the query too slow and always timeout. how can we optimize the query ?
{
mfLjOe(func: type(A)) @filter(eq(field1, "value1")){
b as ~A
}
nCVefd(func: uid(b)) {
B @filter(type(B) AND eq(field2, "value2")) {
c as ~B
}
}
end(func: uid(c)) {
count(uid)
}
}
Your query looks really absurd. A is a type, but then it’s also being used as a field ? (same applies for B). You can try something as follows instead →
{
mfLjOe(func: has(~A)) @filter(eq(dgraph.type, "B") and eq(field1, "value1")) {
b as ~A
}
nCVefd(func: uid(b)) @filter(eq(field2, "value2")){
c as ~B
}
end(func: uid(c)) {
count(uid)
}
}
Also try indexing your index-able objects (string, date time,etc.) for performance improvement