0

I have CosmosDB with Mongo 4.0 API setup on Azure. Locally I run 4.0.x MongoDB instance. They are configured the same way with the same data set.

db.getCollection('route').aggregate(  [
{"$match": {"routes": {"$in": [
    {"from": "ABC ", "to": "DEF"},  {"from": "GHI ", "to": "JKL"}  
    ]}, "_id": {"$ne": {"$oid": "6114f07807dbcb5a260bbe56"}}}}
])

When running this query (with a lot more routes provided) the performance decreases greatly for CosmosDB. For local MongoDB instance the query takes 50ms while on CosmosDB it is 60seconds.

Currently RU limit is set to 800RU, however according to the MAX usage it doesn't go beyond 15% when running this query.

1 Answers1

0

Your activities are rate-limited if the workload on a logical partition consumes more than the throughput allotted to that logical partition. When rate-limiting occurs, you may either raise the database's overall throughput or retry the processes.

You should explore ways to lower the RU charge for queries with charges greater than 50 Rus. If you reduce the RU charge of a query, you'll typically decrease latency as well.

Query optimizations in Azure Cosmos DB are broadly categorized as follows:

• Optimizations that reduce the Request Unit (RU) charge of the query

• Optimizations that just reduce latency

Such as:

  • Avoid or minimize cross partition queries | Docs
  • Leverage In Partition Query
  • Improve proximity
  • Increase provisioned throughput | Docs

Hence, for more information refer this: Troubleshoot query issues when using the Azure Cosmos DB API for MongoDB

Similar kind of discussion has happened in this SO thread.

IpsitaDash-MT
  • 1,326
  • 1
  • 3
  • 7