locked
Count performance (Cosmos DB - mongo) RRS feed

  • Question

  • Hello,

    I'm currently working with a CosmosDB and I have to do some count requests with the Mongo API.

    The issue is that the RequestCharge and the RequestDuration are too high for the usage of the application. All the fields of the concerned queries are well indexed. Here is a sample of a request statistics (obtained with getLastRequestStatistics executed just after a count request):

    {
        "_t" : "GetRequestStatisticsResponse",
        "ok" : 1,
        "CommandName" : "count",
        "RequestCharge" : 7021.44,
        "RequestDurationInMilliSeconds" : NumberLong(10183)
    }

    I also tried with a $match and a $count pipeline, the results are close (and surprisingly consume a bit less RUs):

    {    
        "_t" : "GetRequestStatisticsResponse",
        "ok" : 1,
        "CommandName" : "aggregate",
        "RequestCharge" : 6966.72,    
        "RequestDurationInMilliSeconds" : NumberLong(14988)
    }

    Is there a way/some good practices to optimize count requests?

    Thursday, May 7, 2020 7:17 PM

Answers

  • Which MongoDB API version are you using 3.4 or 3.6?

    Aggregation operations are much faster in 3.6. 

    Please check and let us know. 

    -

    If this answers your query, do click “Mark as Answer” and Up-Vote for the same which might be beneficial to other community members reading this thread .

    And, if you have any further queries do let us know. 


    Monday, May 11, 2020 1:02 PM

All replies

  • Which MongoDB API version are you using 3.4 or 3.6?

    Aggregation operations are much faster in 3.6. 

    Please check and let us know. 

    -

    If this answers your query, do click “Mark as Answer” and Up-Vote for the same which might be beneficial to other community members reading this thread .

    And, if you have any further queries do let us know. 


    Monday, May 11, 2020 1:02 PM
  • Thank you for your response, I'm currently using 3.4 version so I'll migrate to 3.6 to check the performances again!
    Monday, May 11, 2020 10:22 PM