Let say I have 2 “tables”, User
and Post
. A user can have multiple posts.
user: default .
name: string .
post: uid @count .
Which one of these queries is the fastest? This one:
user(func: has(user)) @filter(uid(USER_ID)) {
name
posts: post {
uid
}
}
or this one:
user(func: has(user)) @filter(uid(USER_ID)) {
name
}
var(func: has(user)) @filter(uid(USER_ID)) {
P as post
}
posts(func: uid(P)) {
uid
}
or this one (need to add @reverse
in post
schema):
user(func: has(user)) @filter(uid(USER_ID)) {
name
}
posts(func: has(post)) @cascade {
~post @filter(uid(USER_ID))
uid
}
I prefer posts
to be at same level with (not nested inside) user
in the resulting JSON, but if the performance/disk storage difference is significant, I’m ok with the fastest/cheapest option.