How to influence the placement of predicates in dgraph?

Yes, this is possible, but not exactly as you may think and there is some miss conception about how Dgraph works. The predicates are balanced between groups. Based on disk usage. For now, there’s no way to force where a specific set of predicates will be. But you can increase the time of balancing to infinity. That way you’d bypass the balancing. And then you can use /moveTablet?tablet=name&group=2. That’s a way to force it.

read this Add a Bulk Move Tablet and/or A deterministic scheme for Tablets (Also Geo-Sharding Support) if you wanna know more about it.

But the main problem relies on the predicate context. All YAMLs will use the same predicate, and as Dgraph is based on predicates and not values, it won’t work for you. Unless you have a predicate for each YAML you have. That means if you have thousands of YAMLs, you gonna have thousands of predicates on your schema. And you would have a Type and query for each predicate. This would be hard work to maintain.

Anyway, why this is important for you? to keep a set of predicates in specific groups.

BTW, this isn’t really possible. Groups will be any Alpha (If you have replicas a group will be a set of Alphas). You can’t control this (where the data goes in Alphas level). The logic of constraining nodes (YAMLs) to Alphas is not possible. There’s no way to Dgraph infer a specific node (checking its values) and throw the data to a specific alpha. It could work for Groups (in a different way), not Alphas.

Let’s say that group 3 holds the tablets for that data you are inserting. Dgraph will send it to that Alphas that compound that group (that may be several alphas or a single one). That way works. If you use the infinity balancing bypass and move the tablets to the group you wish. Again, but not in value level, just predicates.

Cheers.

2 Likes