Mongo ChangeStream Slow queries for Aggregate Query

Hi Team,

We have a shared cluster which 5-6 dbs . The RAM is 64GB and diskspace is 960 GB.
We are using changestream where one of our microservice pushes updates to a collection X in our db. There are 3 other microservices(with 3 instances each ) which is subscribed to that changestream using the aggregate pipeline where we only check for operationType as insert … We are using spring mongo db starter for the implementation and have the resume token implementation also done. Now this is our non prod environment where we run some small amount of load testing and there are some entries to collection X.We are occasionally seeing some issues where mongo db team tells us that we are seeing the aggregate command running for resuming at a point where the docsExamined value is around 6298014 records with COLSCAN . This is a lot of seconds and crosses minutes , which makes the CPU utilization to 100 % for the entire cluster. How can we optimize the pipeline to ensure we dont have these many docsExamined value. What is the reason for this high value?

Hello, welcome to the MongoDB community!

Can you share the aggregation and an explain?