Search code examples
azureazure-table-storageazure-cosmosdb-tables

Ordering data in Azure Cosmos Table API


Azure Storage Tables have been superseeded by Azure Cosmos Table API at a significantly higher price point but also with new features like automatic secondary indexing.

One of the pain points using Azure Storage Tables was, that in order to achieve custom ordering of query, we have to redundantly store the data with different Partition/Row-Keys as the documentation states, that

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

However, the next paragraph states, that

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.

Following, the link, i find that

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

So i am a bit confused now, how to achieve ordering when using Cosmos Table API. Is there no ordering at all? Or can i specify ordering with my querys?


Solution

  • For Azure Cosmos Table API, this one is correct: "Query results returned by the Azure Table API in Azure DB are not sorted by partition key or row key".

    So the returned results is no sorting as of now.

    Somebody has asked this issue before at GitHub here.

    And the MS team suggests vote on this user voice. And they may add this basic sort feature in future.

    Hope it helps.