Azure cosmos db - Default order of documents returned by WHERE clause

Viewed 1208

In what order are documents returned for a Select query without an Order by clause?

Example query - SELECT * FROM c WHERE c.type=someType

Is it based on id of the documents or last modified timestamp(_ts) or the timestamp of creation or some random order?

If this info helps - This query is performed in a collection with only one partition whose partitionKey is null, and there are atmost 3 documents for a 'type'

1 Answers

Is it based on id of the documents or last modified timestamp(_ts) or the timestamp of creation or some random order?

Based on my test, if you do not set any sort rule, it will be sorted as default based on the time created in the database,whatever it is partitioned or not.

enter image description here

In above sample documents, the sort will not be changed if I change the id,partition key(that's name) or ts.

Related