Report a Dgraph Bug
What version of Dgraph are you using?
Dgraph Version
Dgraph version : v22.0.0
Dgraph codename : dgraph
Dgraph SHA-256 : bc4cc6d649fa2328df1d9d5702b30e2204934ba0b58cbbfa6816d52e98a9d191
Commit SHA-1 : c36206a
Commit timestamp : 2022-10-21 11:32:45 +0000
Branch : release/v22.0.0
Go version : go1.18.5
jemalloc enabled : true
For Dgraph official documentation, visit https://dgraph.io/docs.
For discussions about Dgraph , visit http://discuss.dgraph.io.
For fully-managed Dgraph Cloud , visit https://dgraph.io/cloud.
Licensed variously under the Apache Public License 2.0 and Dgraph Community License.
Copyright 2015-2021 Dgraph Labs, Inc.
Performance problem
When I run the following query, it is extremely slow:
{
q(func: eq(cid3_1, 717), first: 1000) @filter(eq(brand_1, "GODEX") and le(price_1, 2000)) {
sku_id_1
cid3_1
price_1
}
}
It costs 3.6 seconds!
However, it’s much faster after I remove the le(price_1, 2000) function in filter:
{
q(func: eq(cid3_1, 717), first: 1000) @filter(eq(brand_1, "GODEX")) {
sku_id_1
cid3_1
price_1
}
}
It only costs 67.6ms!
Schema:
Define Types
type Product_1 {
sku_id_1
title_1
brand_1
cid3_1
price_1
click_cnt_1
attrs_1
has_tag_1
relate_sku_1
}
Define Directives and index
sku_id_1: string @index(exact) @upsert .
title_1: string @index(fulltext) .
brand_1: string @index(hash) .
cid3_1: string @index(hash) .
price_1: float @index(float) .
click_cnt_1: int @index(int) .
attrs_1: string @index(term) .
has_tag_1: [uid] @reverse @count .
relate_sku_1: [uid] @count .
Have you tried reproducing the issue with the latest release?
Yes
What is the hardware spec (RAM, OS)?
CPU: Intel(R) Xeon(R) CPU @ 2.60GHz, 16 Cores.
RAM: 32G
OS: CentOS Linux release 7.2
Steps to reproduce the issue (command/config used to run Dgraph).
- Run query without float predicate in filter, record the time cost.
- Run query with float predicate in filter, record the time cost.
And you will see the second query will be much slower.
Slow query:
{
q(func: eq(cid3_1, 717), first: 1000) @filter(eq(brand_1, "GODEX") and le(price_1, 2000)) {
sku_id_1
cid3_1
price_1
}
}
Fast query:
{
q(func: eq(cid3_1, 717), first: 1000) @filter(eq(brand_1, "GODEX")) {
sku_id_1
cid3_1
price_1
}
}
Expected behaviour and actual result.
It’s also fast while using float predicate(with float index) in filter.