Reputation: 1288
I'm having an issue where I perform a query in the Azure portal and it consumes ~5 RU/s, but when I perform the same query in pymongo it throws "Request is Large", indicating that I don't have enough (we have 3000 RU/s provisioned).
How can I find out how many RU/s my pymongo query is consuming from within Python?
EDIT: Is there a way to find the total RU/s being used by the Cosmos (for example by other users?)
Upvotes: 1
Views: 1265
Reputation: 23782
Use runCommand method in Pymongo:
from pymongo import MongoClient
client = MongoClient()
client = MongoClient(
'mongodb://***@***.documents.azure.com:10255/?ssl=true&replicaSet=globaldb')
db = client.testdb
coll = db.coll
result = coll.find_one()
print(coll.find_one())
result = db.command({"getLastRequestStatistics": 1})
print("Last RU Consume:", result["RequestCharge"])
Output:
Got this solution from this link which is not mentioned from official document.
Upvotes: 1