Performance: Index VS Label

as far as I see this will need to be manually implemented in DGraph

You are correct. In Dgraph, you have to handle this yourself.

There are two different options for grouping nodes.

  1. As you suggest, have a group predicate in your schema. And then set this to be the name of the group. With appropriate indexing, you can then search for all members of a group, filter in/out groups when doing normal queries etc.
  2. Instead, you could have a different predicate for each group. E.g. All nodes in group A could have a group_a predicate. All members of group B could have a group_b predicate. Then you can use the has function to filter and search in queries.

We recommend to use the second approach. This is because it scales better and results in lots of smaller predicates rather than one large predicate.

1 Like