error: SC3020. The SQL query text exceeded the maximum limit of 544720 characters in Azure CosmosDB

dmitrii sablin 0 Reputation points
2023-05-10T11:54:33.34+00:00

Hello, I am using Azure Cosmos DB MongoDB shell, and when I perform the QUERY, I receive the error: The SQL query text exceeded the maximum limit of 544720 characters in Azure CosmosDB.

My query is the following:

db.Actions.aggregate([{$match:{type:{$in:["registration","fillform"]}}},{$lookup:{from:"Visits",localField:"value",foreignField:"token",as:"Visit"}},{$unwind:"$Visit"},{$match:{"Visit.url":{$regex:/path=testtest/}}},{$group:{_id:{Date:{$dateToString:{format:"%Y-%m-%d",date:"$date"}},ActionType:"$type"},Count:{$sum:1}}},{$project:{_id:0,Date:"$_id.Date",ActionType:"$_id.ActionType",Count:1}}])

the source C# code via mongo driver the following:

  
   var actions = await _dbContext.Actions
                    .Aggregate()
                    .Match(actionsFilter)
                    .Lookup<Action, Visit, ActionLookedUp>(_dbContext.Visits,
                    (Action output) => output.Value,
                    (Visit visit) => visit.Token,
                    (ActionLookedUp output) => output.Visits)
                    .Unwind<ActionLookedUp>("Visits")
                    .Match(visitsFilter)
                    .Group(GetGroupByExpression(filter.GroupBy), g => new { g.Key, g.Key.Type, Count =                   g.Count() }).ToListAsync();

the response is also can not be more than 10 or even 50mb, because as you can see i use Group

As you can see this query is not too long (just filter, lookup, and group and that’s it) I need to receive groups with count, but I receive the Error. How can I fix it?

I did not find any answer on this issue in the internet (only something like "write to support")

Please help, how can i perform the query and receive the data?

Thanks!

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,901 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SSingh-MSFT 16,371 Reputation points Moderator
    2023-05-10T15:36:41.67+00:00

    Hi dmitrii sablin •,

    Welcome to Microsoft Q&A forum and thanks for using Azure Services.

    We are sorry about the inconvenience you are experiencing with the SQL query limit in Azure Cosmos DB.

    The limits are defined as follows at the standard Microsoft documentation:

    User's image

    However, You can increase any of these SQL query limits by creating an Azure Support request.

    Create new support request using the link by steps mentioned there if you have support plan for exclusive increase in limits for your Cosmos DB.

    In case if you don't have a support plan, do let us know here so that we can check on other options to unblock you. Thanks


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.