Since updating from 7.2.2 to 7.6.2 we are receiving error messages on our queries, that I was not able to solve yet. We did not change the queries and have the system running with multiple Couchbase versions since two years like this. The query is:
SELECT * FROM t USE KEYS $ts
LEFT NEST it ON ANY s IN it.sk SATISFIES s.sk IN t.sk[*].sk END
LEFT JOIN st ON META(st).id=t.st
LEFT NEST p ON META(p).id IN ARRAY IFMISSINGORNULL(s.pr.id, s.sk) FOR s IN t.sk END
LEFT NEST inv ON META(inv).id IN ARRAY META(i).id || '_s' || t.st FOR i IN it END
LEFT JOIN te ON META(te).id IN IFMISSINGORNULL(t.te, IFMISSINGORNULL(ARRAY_IFNULL(it[*].te), IFMISSINGORNULL(s.te, 'default')))
LEFT JOIN ca ON META(ca).id = t.ca.id
LEFT JOIN t AS ma ON META(ma).id=t.ma
The error message we receive is:
{
“code”: 4000,
“msg”: "Sargable index not sarged; pred=anys
in (it
.sk
) satisfies ((s
.sk
) in (array_star((t
.sk
)).sk
)) end, sarg_keys=[(distinct (array (s
.sk
) fors
in (it
.sk
) end))], error=Plan error: sarg.VisitAny: unexpected array id (0) for ANY expression anys
in (it
.sk
) satisfies ((s
.sk
) in (array_star((t
.sk
)).sk
)) end",
…
}
The index that is related to the issue is:
CREATE INDEX `idx_it_sk` ON `dp`.`d`.`it`((distinct (array (`s`.`sk`) for `s` in `sk` end)))
As soon as this index is deleted the query works, but of course without using the index which is not admired. Dropping and recreating did not solve the issue.
I can not find anything similar in the forum and can not wrap my head around what needs to be done to fix this. Help is highly appreciated.