【发布时间】:2019-12-12 14:43:46
【问题描述】:
我正在使用 DocumentDB。给定索引策略:
messageType:字符串 - 精度 -1
deviceId:字符串 - 精度 -1
查询 1:
SELECT * FROM c WHERE c._ts >= 1563721200 AND c._ts < 1563807600 AND c.messageType = 'attack' AND c.deviceId >= 'A' AND c.deviceId < 'Z'
查询 2:
SELECT * FROM c WHERE c._ts >= 1563721200 AND c._ts < 1563807600 AND c.messageType = 'attack' AND c.deviceId >= 'A' AND c.deviceId < 'Z' ORDER BY c._ts DESC
执行代码:
var query = dbClientSource.CreateDocumentQuery<Document(UriFactory.CreateDocumentCollectionUri(db, collection),
sql,
new FeedOptions { MaxItemCount = 100, EnableCrossPartitionQuery = true })
.AsDocumentQuery();
while (query.HasMoreResults)
var result = await query.ExecuteNextAsync<Telemetry>();
查询 1 有效,但查询 2 抛出异常:
{
"code": "ServiceUnavailable",
"message": "The request failed because the client was unable to establish connections to 1 endpoints across 1 regions. The client CPU was overloaded during the attempted request.
}
不同的是“ORDER BY”命令。 有什么解决办法吗?
【问题讨论】:
-
partitionKey 是什么?
-
PartitionKey 是 deviceId。由于查询使用“EnableCrossPartitionKey”,我认为可能不需要。
标签: database indexing azure-cosmosdb azure-sdk-.net