Devarajan Roopeshwar
Devarajan Roopeshwar

Reputation: 53

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

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'

Upvotes: 5

Views: 2357

Answers (1)

Jay Gong
Jay Gong

Reputation: 23767

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.

Upvotes: 5

Related Questions