I’ve been playing around with play.dgaph.io, and have noticed something odd with the has() function. Some requests return quickly, while others take almost 20 seconds to return. I’ve only tested this on play.dgraph.io so far.
Running the following query:
{
q(func:has(name)) {
name
}
}
typically returns in 17-19 seconds, and occasionally doesn’t return in the 20 second timeout. e.g.
{
...
"extensions": {
"server_latency": {
"parsing_ns": 51811,
"processing_ns": 17574771692,
"encoding_ns": 583096,
"total_ns": 17575497225 # 17.58 secs
},
"txn": {
"start_ts": 343271
},
"metrics": {
"num_uids": {
"_total": 603,
"name": 603
}
}
}
}
This seemed slow to me, so ran some more tests. Since there are 603 results, I tried two more queries.
{
q(func:has(name), first: 600) {
name
}
}
typically returns in about 1.6 seconds:
{
...
"extensions": {
"server_latency": {
"parsing_ns": 65559,
"processing_ns": 1656242021,
"encoding_ns": 901675,
"total_ns": 1657286896 # 1.66 secs
},
"txn": {
"start_ts": 343271
},
"metrics": {
"num_uids": {
"_total": 600,
"name": 600
}
}
}
}
while setting the ‘first’ value to slightly above the number of results similarly has the same issue as the first request:
{
q(func:has(name), first: 610) {
name
}
}
gave
{
...
"extensions": {
"server_latency": {
"parsing_ns": 69261,
"processing_ns": 18813905219,
"encoding_ns": 629217,
"total_ns": 18814682766 # 18.81 secs
},
"txn": {
"start_ts": 343271
},
"metrics": {
"num_uids": {
"_total": 603,
"name": 603
}
}
}
}
Likewise, even with the limit set to less than 603, if we do any sort of ordering, we get the really long processing time:
{
q(func:has(name), first: 600, orderasc: name) {
name
}
}
gave
{
...
"extensions": {
"server_latency": {
"parsing_ns": 57129,
"processing_ns": 17719464401,
"encoding_ns": 809650,
"total_ns": 17720402882 # 17.72 secs
},
"txn": {
"start_ts": 343271
},
"metrics": {
"num_uids": {
"_total": 600,
"name": 600
}
}
}
}
I’m not sure how the has() function works internally, or if perhaps the version of Drgraph running on play.dgraph.io is and older version, but it doesn’t seem to have been optimized here.