Hi Devs,
I have a performance question on retrieving all nodes having any of a given set of predicates and the respective values.
When the set has only a single predicate, I can do the following (when it is a property having a literal value):
{
result (func: has(prop)) {
uid
prop
}
}
and this when it is an edge leading to another node:
{
result (func: has(edge)) {
uid
edge { uid }
}
}
When I have multiple predicates, I cannot use the func: has(...)
because it only supports a single predicate. Then my query looks like:
{
result (func: has(dgraph.type)) @filter(has(prop) OR has(edge)) {
uid
prop
edge { uid }
}
}
I have a few questions:
- What performance impact should I expect when I 10-fold the size of the schema or graph (assuming fixed result size)? I presume the query performance scales linearly with result size.
- Is there a better alternative to
@filter
? I have experienced very poor performance on a small size graph. Or should that scale well? - When I send those queries to alphas that do not host some of those predicates then the query will be forwarded to alphas of the group that does host those predicates. Would you say there is a benefit to only have predicates of one group in such a query and send it to alphas of that group only given this avoids extra dgraph cluster communication? Or would you argue that overhead is negligible?