Which one is bettwer, WHERE ANY IN or just IN?

the docs have a fields
tags = {“1”, “2” },


to find out docs have specific tag, which is the better way?
SELECT * FROM default WHERE ANY tag In default.tags SATISFIES tag = “1” END
SELECT * FROM default WHERE “1” IN default.tags

and why?

thanks a lot.

With Couchbase 4.5, you can create an array index. ANY … IN will be able to use the array index, whereas IN will not. ANY also lets you do more complex comparisons. But for simple equality, and if you don’t need the performance of an array index, you can use either one.

1 Like