Simple graphql query takes too long to process

Hello! Recently I faced a strange issue.
My schema looks like this:

type Domain {
    domain: String! @id
    domain_utf8: String
}

There are 70+ million records of this type in the db.
When I send a dql-query for getting an object by the domain name it replies quickly as it has to be.
Query:

{
  me(func: eq(Domain.domain, "google.com")) {
   Domain.domain   
  }
}

Response:

{
    "data": {
        "me": [
            {
                "Domain.domain": "google.com"
            }
        ]
    },
    "extensions": {
        "server_latency": {
            "parsing_ns": 126427,
            "processing_ns": 3263345,
            "encoding_ns": 56107,
            "assign_timestamp_ns": 1494263,
            "total_ns": 5047142
        },
        "txn": {
            "start_ts": 252
        },
        "metrics": {
            "num_uids": {
                "Domain.domain": 1,
                "_total": 1
            }
        }
    }
}

But when I try to do the same using graphql a request takes 10 times longer!
Query:

query getDomain {
    getDomain(domain: "google.com") {
        domain
    }
}

Response:

{
    "data": {
        "getDomain": {
            "domain": "google.com"
        }
    },
    "extensions": {
        "touched_uids": 3,
        "tracing": {
            "version": 1,
            "startTime": "2021-10-14T20:27:53.285329588+03:00",
            "endTime": "2021-10-14T20:27:55.651524893+03:00",
            "duration": 2366195247,
            "execution": {
                "resolvers": [
                    {
                        "path": [
                            "getDomain"
                        ],
                        "parentType": "Query",
                        "fieldName": "getDomain",
                        "returnType": "Domain",
                        "startOffset": 206806,
                        "duration": 2365983197,
                        "dgraph": [
                            {
                                "label": "query",
                                "startOffset": 307350,
                                "duration": 2365880988
                            }
                        ]
                    }
                ]
            }
        }
    }
}

I had tried to recreate the index of the domain field and even to recreate the cluster using export and bulk loader but nothing helped.

In the log I found the following lines:

I1014 20:08:58.588155  836869 draft.go:211] Operation started with id: opRollup
I1014 20:10:44.397376  836869 admin.go:674] Updating GraphQL schema from subscription.
I1014 20:10:44.398484  836869 mutation.go:204] Max open files limit: 1048576
I1014 20:10:44.398932  836869 index.go:783] Deleting indexes for Domain.domain

Could it be related to the issue?

I use dgraph v21.03.2

1 Like

As I have found out a graphql query is transformed into a dql query during processing.
So the graphql query is transformed into this:

query {
    getDomain(func: eq(Domain.domain, "google.com")) @filter(type(Domain)) {
        Domain.domain : Domain.domain
        dgraph.uid : uid
    }
}

Without the type filter it is executed in ~ 90ms.
With filter ~ 1900ms

You can make a custom query in GraphQL with the DQL solution.

Is it possible to test in old versions? just to check if it is a regration.

how is your cluster configured?