What I want to do
I want to run a basic query. The schema is the following:
type File {
id: ID!
name: String! @search(by: [hash, regexp])
buckets: [Bucket] @hasInverse(field: inBucket)
}
type Bucket {
id: ID!
name: String! @search(by: [hash, regexp])
inFiles: [File]
parameters: [Parameter] @hasInverse(field: inBuckets)
}
type Parameter {
id: ID!
key: String! @search(by: [hash, regexp])
value: String @search(by: [hash, regexp])
inBuckets: [Bucket]
}
As an example, there is one parameter which is linked to ~2 million Buckets, which are again linked to roughly 40000 files.
The following query is taking many many minutes to finish:
query {
var(func: type(Parameter)) @filter(eq(Parameter.key, "someKey")) {
Parameter.inBuckets {
Bucket.inFiles {
files as uid
}
}
}
query(func: uid(files)) {
count(uid)
}
}
Question
Is there a way to speed this up. Would it make sense to have links direktly from parameters to files to improve performance?
In other cases with way less links, the performance is as expected.