Performance 如果我们已经将分区键设置为FeedOption,那么查询是否应该包含分区键?

Performance 如果我们已经将分区键设置为FeedOption,那么查询是否应该包含分区键?,performance,linq,azure-cosmosdb,Performance,Linq,Azure Cosmosdb,我正在使用分区键为=“deviceId”的文档数据库。 以下2个代码之间是否有任何不同: var fo = new FeedOption{ PartitionKey= new PartitionKey("A1234") }; var partitionKeyInQuery= dbClient.CreateDocumentQuery(d => d.deviceId = "A1234" and d.type==1, fo); var noPartitionKeyInQuery = dbClie

我正在使用分区键为=“deviceId”的文档数据库。 以下2个代码之间是否有任何不同:

var fo = new FeedOption{ PartitionKey= new PartitionKey("A1234") };
var partitionKeyInQuery= dbClient.CreateDocumentQuery(d => d.deviceId = "A1234" and d.type==1, fo);
var noPartitionKeyInQuery = dbClient.CreateDocumentQuery(d => d.type==1, fo);

当在FeedOption中应用PartitionKey时,我应该在WHERE子句中添加“deviceId”吗?

我相信在性能上没有差别。RequestCharge是相同的,where子句使查询特定于分区,即消除了跨分区查询

从文件中:

查询分区容器

当您在分区容器中查询数据时,Cosmos DB会自动将查询路由到与过滤器中指定的分区键值(如果有)相对应的分区。例如,此查询只路由到包含分区键“XMS-0001”的分区

//使用分区键进行查询
IQueryable query=client.CreateDocumentQuery(
CreateDocumentCollectionUri(“db”,“coll”))
其中(m=>m.MetricType==“温度”和&m.DeviceId==“XMS-0001”);

不过,看起来他也在询问差异(即结果是否不同)非常感谢您提供的信息。我想知道两个代码之间的RUs和性能。结果是一样的。
// Query using partition key
IQueryable<DeviceReading> query = client.CreateDocumentQuery<DeviceReading>(
    UriFactory.CreateDocumentCollectionUri("db", "coll"))
    .Where(m => m.MetricType == "Temperature" && m.DeviceId == "XMS-0001");