Reactive @Aggregation causes Mongo Atlas alerts


While getting data from the Aggregation query in the Reactor approach using Spring Data I have observed that even if I’m getting a few hundred of results, the Mongo Atlas shows only 32 returned documents always.

The 32 is a default reactor.bufferSize.x in Flux.

All details can be found here: Spring Reactive Mongo @Aggregation causes Mongo Atlas alerts · Issue #4319 · spring-projects/spring-data-mongodb · GitHub

Do you have any idea why it behaves like this? How it can be fixed? Is that issue on the driver or the Spring data side?

Best regards,

Hi @Bartosz_Skorka and welcome to the MongoDB Community Forum :slight_smile:

The alert message as mentioned:

I have observed that one of my queries caused a lot of Mongo Atlas alerts related to Examined / Returned ratio - “Query Targeting: Scanned Objects / Returned has gone above 1000”.

is explained in the Query Targeting Documentation, which says, the query is scanning more documents than the number of documents getting retuned from the query.

This alert, however, may be resolved by using proper indexing in the collection. The Indexing Strategies documentation will be a good resource to start with.

Further, it would be helpful if you could share some details regarding the error being seen:

  1. A sample document with the query you are trying to use.
  2. he explain output for the query being used.
  3. Does the same query returns correct number of documents are returned without the Spring Data MongoDB Reactive library?
  4. Can you also confirm if the issue of returning lesser number of document in Atlas is only seen through the application, or it happens when you querying through Atlas/Compass/Shell too.

In addition, if you are an Atlas customer, would recommend you to contact Atlas Customer support for detailed assessment.

Let us know if you have any further queries.

Best Regards