How can we improve Azure Cosmos DB?

MongoDB API : aggregation operation is too slow

the aggregation operation is too slow ...

57 votes
Vote
Sign in
(thinking…)
Sign in with: oidc
Signed in as (Sign out)
You have left! (?) (thinking…)
wenlai shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

We are currently working on this feature and have made it available in Preview in the Azure Portal.

Please feel free to test Aggregation Pipeline support for your MongoDB API accounts in Cosmos DB by opening your MongoDB API account, then clicking on “Preview” tab on left hand side and then Enable for Aggregation Pipeline.

While there please feel free to test support for MongoDB 3.4 support as well as Per-Document TTL support.

Thank you for your request and votes.

9 comments

Sign in
(thinking…)
Sign in with: oidc
Signed in as (Sign out)
Submitting...
  • Ryan Kelley commented  ·   ·  Flag as inappropriate

    Could you please comment back on the status of this? We are seeing exponentially slower aggregation queries on Azure versus locally.

  • Anonymous commented  ·   ·  Flag as inappropriate

    Any updates on this. I thought improvements were supposed to be released on April 2018

  • Anonymous commented  ·   ·  Flag as inappropriate

    Add my vote, for same collection on my machine query takes in mongo 0.4s in azure it takes 4s

  • Jon Leavitt commented  ·   ·  Flag as inappropriate

    It doesn't look like $ROOT is supported, making GroupBy and Distinct calls with the C# mongo driver inconsistent. Is there a workaround besides adding every field manually?

  • AdminAzure Cosmos DB Team (Product Manager, Microsoft Azure) commented  ·   ·  Flag as inappropriate

    replaceRoot support is on our roadmap. The workaround currently is to use simple $project: { _id:0, "<document_root>":1 } stage instead. It will give pretty much same results, except that it will include the name of the field used as a new document_root as well, which you can filter out (or simply omit) on the client side.

  • Omid commented  ·   ·  Flag as inappropriate

    Currently CosmosDb Mongo API does not support ReplaceRoot in Aggregate pipeline features. This feature is very-powerful while working with grouping and need to extract properties for Entity mapping in C#, .As<TEntity>().

    var latestVersions = BsonCollection.Aggregate()
    .Sort(Builders<BsonDocument>.Sort.Descending(nameof(BaseEntity.Revision)))
    .Group(new BsonDocument
    {
    {"_id", new BsonDocument("UniqueIdentifier", "$UniqueIdentifier")},
    {"LatestVersion", new BsonDocument("$first", "$$ROOT")}
    };)
    .ReplaceRoot(g => g["LatestVersion"]) //Azure Cosmos Db Does not support this.
    .As<TEntity>()
    .Match(filterExpression)
    .Match(e => includeDeleted || e.IsDeleted == false)
    .Sort(sortDefinition);

Feedback and Knowledge Base