I made this pull request because I ran into an issue on a project I am working at. Even though we have indexes set on MongoDB it makes certain querys excruciatingly slow. Bug I mention can be read about on this link: bit.ly/MongoDBSortBug
TL;DR: MongoDB prioritises indexes which enable it non-blocking sort in aggregation pipelines. Therefore it might choose index that is optimal for sort but not the query itself. It can be "fixed" if you put project between match and sort.
I made this pull request because I ran into an issue on a project I am working at. Even though we have indexes set on MongoDB it makes certain querys excruciatingly slow. Bug I mention can be read about on this link: bit.ly/MongoDBSortBug
TL;DR: MongoDB prioritises indexes which enable it non-blocking sort in aggregation pipelines. Therefore it might choose index that is optimal for sort but not the query itself. It can be "fixed" if you put project between match and sort.