Mongoose find query with populate returns error on Azure MongoDB after query results hit 500+ Mongoose find query with populate returns error on Azure MongoDB after query results hit 500+ azure azure

Mongoose find query with populate returns error on Azure MongoDB after query results hit 500+


The SQL query exceeded the maximum number of 'OR' operators. The allowed limit is 500.

Based on your error log, I presume that you are using Cosmos DB Mongo API. In fact, CosmosDB is an independent server implementation that does not directly align with MongoDB server versions and features.

CosmosDB supports a subset of the MongoDB API and translates requests into the CosmosDB SQL equivalent. CosmosDB has some different behaviours and results. But the onus is on CosmosDB to improve their emulation of MongoDB.

I suggest you you could split the number of your query data per batch to temporarily avoid this limitation. I also searched similar case related to limitation:The SQL query text exceeded the maximum limit of 30720 characters in Azure CosmosDB.

Certainly, you could add feedback here to get official assistance or consider using MongoDB Atlas on Azure if you'd like full MongoDB feature support.

Hope it helps you.