Why is a COUNT in CosmosDB more expensive than listing the actual documents?

Viewed 118

I tried a query like:
SELECT VALUE COUNT(1) FROM c WHERE <a few equality conditions and a 'date greater than' condition>
on a partitioned collection (cross-partition query).

I also tried SELECT * FROM c WHERE <same conditions>

To my surprise, the SELECT * version cost less than SELECT VALUE COUNT(1):

  • for 1 returned doc: 17 RU vs 21 RU
  • for 45 returned docs: 22 RU vs 460 RU !!

Does anyone have an explanation on why this happens?

0 Answers
Related