Hi,
I have a setup that I can switch between dgraph versions easily. After v1.0.12 release, I was comparing my queries to make sure if I can switch to v1.0.12 in production but I found one complex query to run consistently slower in v1.0.12 compared to v1.0.11.
The query is my longest one and might need improvement in the new version and it is:
{
var(func: eq(serial, "MY-PRODUCT")) {
PRODUCTSELF as uid
FEATURES as has_feature @filter(eq(code,["COLOR"]) )
garment_of {
GENDER as gender
type_of {
TYPE as uid
}
}
DESC as described_as
}
prod(func: eq(locale,"CA::en")) @cascade {
locale
products @filter(
eq(is_published, true)
and eq(has_thumbnail,true)
and eq(has_productURL,true)
and not uid(PRODUCTSELF)
and (eq(described_as, "") or not eq(described_as, val(DESC)))
)
@facets(is_in_stock,updated_at)
@facets(eq(is_in_stock,true) and gt(updated_at,'$(expr $(date +%s) - 172800)'))
{
is_published
has_thumbnail
has_productURL
serial
garment_of @filter( eq(gender,"u") or eq(gender,val(GENDER)) ) {
gender
type_of @filter(uid(TYPE)) {
type_name
}
}
has_feature @filter(uid(FEATURES)) {
locale
code
value
}
}
}
}
The schema I use is:
product_of : uid @reverse @count .
type_of : uid @reverse @count .
garment_of : uid @reverse @count .
serial : string @count @index(exact) .
described_as : string @count @index(term) .
is_published : bool @count @index(bool) .
has_thumbnail : bool @count @index(bool) .
has_productURL : bool @count @index(bool) .
updated_at : dateTime @index(day) .
shop_id : string @count @index(exact) .
shop_name : string @count @index(exact) .
prefix : string @count @index(exact) .
type_id : string @count @index(exact) .
is_generic : bool @count @index(bool) .
garment_id : string @count @index(exact) .
gender : string @count @index(exact) .
article_size_id : string @count @index(exact) .
products : uid @reverse @count .
shop_country : string @count @index(exact) .
language : string @count @index(exact) .
locale: string @count @index(exact) .
is_in_stock: bool @count @index(bool) .
code: string @count @index(exact) .
value: string @count @index(exact) .
All predicates have indexing and I assume they are correct as the older version of dgraph is querying near 40% faster. I am checking on http and grpc btw.
Is this anyone else noticed or it is an edge case that only affects me?
average query time (after 100 runs):
v1.0.11: 189156741.4 ns
v1.0.12: 289063134.8 ns