在 Azure Cosmos 中订购数据 Table API

Ordering data in Azure Cosmos Table API

Azure 存储 Table 已被 Azure Cosmos Table API 取代,价格要高得多,而且还具有自动二级索引等新功能。

使用 Azure 存储 Tables 的痛点之一是,为了实现查询的自定义排序,我们必须冗余存储具有不同 Partition/Row-Keys 的数据作为 documentation 表示,

Query results returned by the Table service are sorted in ascending order based on PartitionKey and then by RowKey.

然而,下一段指出,

Query results returned by the Azure Table API in Azure DB are not sorted by partition key or row key. For a detailed list of feature differences, see differences between Table API in Azure Cosmos DB and Azure Table storage.

以下 link,我发现

Query results returned by the Table API aren't sorted in partition key/row key order as they're in Azure Table storage.

所以我现在有点困惑,如何在使用 Cosmos 时实现排序 Table API。根本就没有顺序吗?或者我可以在查询中指定顺序吗?

对于 Azure Cosmos Table API,这个是正确的:"Query results returned by the Azure Table API in Azure DB are not sorted by partition key or row key"。

所以返回的结果目前没有排序。

之前有人在 GitHub here 上问过这个问题。

MS 团队建议对此进行投票 user voice。他们将来可能会添加此基本排序功能。

希望对您有所帮助。

我从 GitHub 线程中找到的有关此主题的其他信息:

CosmosDB Tables SDK 的最新预览版(0.11.0-预览版)支持 OrderBy: https://github.com/MicrosoftDocs/azure-docs/issues/26228#issuecomment-471095278