OFFSET LIMIT clause one of the latest additions to the Azure Cosmos DB. Skip/Take function was a big request from users and Cosmos DB team listened users and deliver this functionality. If you think Cosmos DB is missing a feature and if you have a new idea, you can use Feedback Forums to give feedback to Cosmos Db team.
OFFSET LIMIT clause let you skip x number of results then
take y numbers of values from the query. Count for OFFSET and Limit are integer and both are required. In other words, You must use LIMIT if you use OFFSET.
Addition to OFFSET and LIMIT, you might use ORDER BY clause
if you like to order the results before you start to skip data. The
biggest limitation of OFFSET/LIMIT clause is; CROSS-PARTITION queries are not
supported by OFFSET/LIMIT clause. Queries must use Single Partition. There is already a request to
make this function work in cross-partition and Cosmos DB team has been working
on it.
Let's look at some examples. In the following example, I skip 1 result then take 1 result.
SELECT * FROM c
WHERE c.OwnerUserId = 1
OFFSET 1 LIMIT 1
Here is some interesting stats about this query results from the Data Explorer.
No comments:
Post a Comment