gpt4 book ai didi

c# - 使用 IList.Contains(partition) 进行具有多个分区的 DocumentDb 查询

转载 作者:行者123 更新时间:2023-12-03 03:03:36 24 4
gpt4 key购买 nike

如果查询筛选器使用 IList Contains 方法而不是显式对分区进行 OR 运算,Azure DocumentDB 能否跨分区并行查询?

例如

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>();

最佳答案

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

关于c# - 使用 IList.Contains(partition) 进行具有多个分区的 DocumentDb 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46694334/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com