Filtering one collection using DBRef from a second one that refers to another third

Hello @Javier_Blanco,

I don’t know what is the reason for the slow query. Are there any indexes on these collections? Did you follow the rules of the aggregation optimization (the link I had included earlier). Also, the query behavior is depending upon factors like Query Selectivity.

May be, you have to try the queries (both of them) on a smaller sample set of documents from the two collections, and also Analyze Query Performance.

1 Like