@@ -1819,17 +1819,17 @@ func langForFunc(langs []string) string {
18191819 return langs [0 ]
18201820}
18211821
1822- func planForEqFilter (fc * functionContext , pred string , uidlist []uint64 ) {
1823- checkUidEmpty := func (uids []uint64 ) bool {
1824- for _ , i := range uids {
1825- if i == 0 {
1826- return false
1827- }
1822+ func checkUidZero (uids []uint64 ) bool {
1823+ for _ , uid := range uids {
1824+ if uid == 0 {
1825+ return true
18281826 }
1829- return true
18301827 }
1828+ return false
1829+ }
18311830
1832- if ! checkUidEmpty (uidlist ) {
1831+ func planForEqFilter (fc * functionContext , pred string , uidlist []uint64 ) {
1832+ if checkUidZero (uidlist ) {
18331833 // We have a uid which has 0 in it. Mostly it would happen when there is only 0. But any one item
18341834 // being 0 could cause the query planner to fail. In case of 0 being present, we neeed to query the
18351835 // index itself.
@@ -1912,6 +1912,14 @@ func parseSrcFn(ctx context.Context, q *pb.Query) (*functionContext, error) {
19121912 }
19131913 }
19141914
1915+ generateIneqTokens := true
1916+ if fc .fname != eq && q .UidList != nil && uint64 (len (q .UidList .Uids )) < Config .TypeFilterUidLimit {
1917+ if ! checkUidZero (q .UidList .Uids ) {
1918+ fc .n = len (q .UidList .Uids )
1919+ generateIneqTokens = false
1920+ }
1921+ }
1922+
19151923 var tokens []string
19161924 var ineqValues []types.Val
19171925 // eq can have multiple args.
@@ -1947,6 +1955,9 @@ func parseSrcFn(ctx context.Context, q *pb.Query) (*functionContext, error) {
19471955 lang = q .Langs [0 ]
19481956 }
19491957
1958+ if ! generateIneqTokens {
1959+ continue
1960+ }
19501961 // Get tokens ge/le ineqValueToken.
19511962 if tokens , fc .ineqValueToken , err = getInequalityTokens (ctx , q .ReadTs , attr , f , lang ,
19521963 ineqValues ); err != nil {
@@ -1958,6 +1969,10 @@ func parseSrcFn(ctx context.Context, q *pb.Query) (*functionContext, error) {
19581969 fc .tokens = append (fc .tokens , tokens ... )
19591970 }
19601971
1972+ if ! generateIneqTokens {
1973+ return fc , nil
1974+ }
1975+
19611976 // In case of non-indexed predicate, there won't be any tokens. We will fetch value
19621977 // from data keys.
19631978 // If number of index keys is more than no. of uids to filter, so its better to fetch values
0 commit comments