Slow query on 10 millions records of data when applying grouping aggregation

Our previous implementation was done on My SQL, and due to the large data added we suggested to move to mongo db, we’ve lost a lot of time with Mongo Db that i think it is not a solution for this type or size of Data, and my sql was honestly faster in this type of querying