Naveen Prasath
Naveen Prasath

Reputation: 549

Utilize Indexing to Get Total Count of Records in Cosmos DB

I need to retrieve the Total count of the collection filtered by some column. The collection volume is 500K records. The below given is the query used to retrieve total count of available records in the collection. SELECT COUNT(1) FROM c where c.Column1 IN ('Data2'). Here, this queries retrieves data from multiple sets with continuation token. This delays the total count result. Can someone please let me know if we can use the indexing to increment the query performance without increasing the RU's?

Upvotes: 1

Views: 1323

Answers (1)

Jay Gong
Jay Gong

Reputation: 23782

Can someone please let me know if we can use the indexing to increment the query performance without increasing the RU's?

I have to say no such easy way to improve query performance without increasing the RUs setting. If so, the RUs setting becomes meaningless.

Per my knowledge, you could consider improving performance from the following 3 aspects:

Partitioning

You could set partition keys in your database and query with a filter clause on a single partition key so that it needs lower latency and consumes lower RUs.

Throughput

You could set the throughput a bit larger so that Azure Cosmos DB performance in unit time will be greatly improved. Of course, this will lead to higher costs.

Indexing Policy

The use of indexing paths can offer improved performance and lower latency.However,your query property does't have any sub property.So, I think the default index is just fine.

For more details, I recommend that you refer to the official performance documentation.

Hope it helps you.

Upvotes: 1

Related Questions