Filtering relations performance

What I want to do

Let’s imagine that I have a graph with ~200 authors and each author can have multiple related entities (posts, photos,videos, …). These related entities can be ~1M for each author. For example, an author can have 1M posts.

If I want to search for posts for a specific author is the following query efficient?

query {
  queryAuthor(authorID: "0x2") {
    posts(filter: {
      score: {
        gt: 10
      and: {
        completed: true
    }) {

Are indexes defined inside posts used? Let’s say that I have an index on score field.
Composite indexes are not supported yet, right? So for example in the above case only the index defined in the score will be used?

Hi @Davide_Icardi - welcome to the Dgraph forums!

I think you mean indices in the way traditional RDBMSes use them. Indices in Dgraph are somewhat different. They’re used to support searching (exact, hash, etc).

The performance characteristics of a query in Dgraph is dependent upon the predicates. Because Dgraph “shards”* storage by predicate, this is quite equivalent to having an index on every column in a traditional RDBMS. I didn’t quite cover it, but I think you should read this blog post on how things work under the hood. No code involved.

* “shard” is probably not the right word to use. But basically Dgraph stores data by groups of predicates.