Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(core): Fix performance issue in type filter #9065

Merged
merged 7 commits into from
Apr 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed some tests
harshil-goel committed Apr 12, 2024
commit 73974fb1b931e518eb510b4825da7ab7cfd76f36
11 changes: 10 additions & 1 deletion worker/task.go
Original file line number Diff line number Diff line change
@@ -1778,6 +1778,15 @@ func parseSrcFn(ctx context.Context, q *pb.Query) (*functionContext, error) {
fc.tokens = append(fc.tokens, tokens...)
}

checkUidEmpty := func(uids []uint64) bool {
for _, i := range uids {
if i == 0 {
return false
}
}
return true
}

// In case of non-indexed predicate, there won't be any tokens. We will fetch value
// from data keys.
// If number of index keys is more than no. of uids to filter, so its better to fetch values
@@ -1792,7 +1801,7 @@ func parseSrcFn(ctx context.Context, q *pb.Query) (*functionContext, error) {
fc.tokens = fc.tokens[:0]
fc.n = len(q.UidList.Uids)
case q.UidList != nil && fc.fname == eq && strings.HasSuffix(attr, "dgraph.type") &&
int64(len(q.UidList.Uids)) < Config.TypeFilterUidLimit:
int64(len(q.UidList.Uids)) < Config.TypeFilterUidLimit && checkUidEmpty(q.UidList.Uids):
fc.tokens = fc.tokens[:0]
harshil-goel marked this conversation as resolved.
Show resolved Hide resolved
fc.n = len(q.UidList.Uids)
default: