Query CosmosDb - where array contains item(s) from array

前端 未结 3 778
执笔经年
执笔经年 2021-01-01 20:09

I don\'t know if there is a word for this, guess there is, but right now I couldn\'t explain it better than \"where array contains item(s) from array\".

It might sou

3条回答
  •  不思量自难忘°
    2021-01-01 21:09

    Apart from the fact that using UDF looks as the easier option, i would not use UDFs in your query's filter, since it compromises the performance of your query. I faced the same problem in my work environment, where things are designed to use UDFs to help in the queries, but the reality is that most of the times we are doing queries by using single values, and using UDF will actually result on the query not using the index. So in that case if you need to validate multiple values in the array, depending on the volume of values you need to validate, you can always write something like ARRAY_CONTAINS(c, 1) or ARRAY_CONTAINS(c, 2) or ....

    It doesn't look so elegant solution, but will ensure that it will use the index and will do the best performance in your query.

提交回复
热议问题