aravindnc / mongoose-aggregate-paginate-v2

A cursor based custom aggregate pagination library for Mongoose with customizable labels.
MIT License
131 stars 23 forks source link

Added match stage before facet to improve performance #61

Closed Akalanka47000 closed 2 months ago

Akalanka47000 commented 2 months ago

Hello, I happened to notice that facet, if used as the first stage in an aggregate pipeline doesn't use indexes which is a bit problematic. It's described in detail here.

This pr extracts the match stage from the pipeline and adds it before the facet which solves this issue

aravindnc commented 2 months ago

Excellent. Thanks @Akalanka47000