使用IList.Contains(分区)的多个分区的DocumentDb查询

时间:2017-10-11 17:34:21

标签: c# azure azure-cosmosdb

如果查询过滤器使用IList Contains方法而不是显式对分区进行OR运算,Azure DocumentDB可以跨分区并行化查询吗?

E.g。

DocumentClient client = ...
Uri documentUri = ...
FeedOptions = new FeedOptions { EnableCrossPartitionQuery = true };

IList<string> partitions = new List<string> { "x", "y", "z" };
Expression<Func<ResourceType, bool>> filter =
    (ResourceType rt) => partitions.Contains(rt.PartitionId);

IDocumentQuery<ResourceType> queryable =
    client.CreateDocumentQuery<ResourceType>(documentUri, feedOptions)
          .Where(filter)
          .AsDocumentQuery();
FeedResponse<ResourceType> response = await queryable.ExecuteNextAsync<ResourceType>();

1 个答案:

答案 0 :(得分:1)

是,包含查询(翻译为SQL IN)将被批处理/并行化到匹配的分区。与@ fred-han提及一样,请设置FeedOptions.MaxDegreeOfParallelism