Make COUNT() aware of indexes
Queries with COUNT() or other aggregates are very expensive and all appear to be scan driven vs. index driven.
I have 50k documents in collection, each has "Type" property with string value. The indexing policy is default.
The following simple query consumes 615 RUs:
SELECT VALUE COUNT(1) FROM x WHERE x.Type ='Content'
The result is 9738 records.
The query metrics are:
So what we see is that database reads all "Contents" and than counts them. But it's enough to just count the index entries not to read all "Contents".
We have started work on this feature. Will update here when this becomes generally available.
Thank you for your request and votes.
Jahmai Lay commented
Any update on this? Aggregates are so expensive it's making using cosmos prohibitive. At minimum Count should be RU cheap.
Cararo, Edinilson commented
Yes please in the mongodb API this is killing our through put!