Skip to content

Commit

Permalink
fix(DQL): optimize query for has function with offset. (#7727)
Browse files Browse the repository at this point in the history
Fixes DGRAPH-574.

This PR reduces the latency of the `has` function slightly. For example the given query:-
```
{
    me(func: has(actor.film), first: 10, offset: 300000){
       name@en
    }
}
```
when run on the `21million` dataset takes around `80` milliseconds to execute as compared to earlier around `93` milliseconds.

Machine Specs:-
```
Model Name:	MacBook Pro
  Model Identifier:	MacBookPro16,1
  Processor Name:	6-Core Intel Core i7
  Processor Speed:	2.6 GHz
  Number of Processors:	1
  Total Number of Cores:	6
  L2 Cache (per Core):	256 KB
  L3 Cache:	12 MB
  Memory:	16 GB
```

Note:-
This does not optimize for the `has` function on predicates with the `@lang` tag.
  • Loading branch information
minhaj-shakeel authored Apr 20, 2021
1 parent 69c8389 commit 214c5df
Show file tree
Hide file tree
Showing 5 changed files with 407 additions and 337 deletions.
2 changes: 2 additions & 0 deletions protos/pb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ message Query {
int32 cache = 14;
int32 first = 15; // used to limit the number of result. Typically, the count is value of first
// field. Now, It's been used only for has query.
int32 offset = 16; // offset helps in fetching lesser results for the has query when there is
// no filter and order.
}

message ValueList {
Expand Down
Loading

0 comments on commit 214c5df

Please sign in to comment.