Open
Description
Currently the entire MongoDB pipeline is run and only in the last stage the totals are computed and the limits are being set.
If we have heavy aggregation pipelines with lookups this will make mongodb perform the entire lookup on the entire query, we can improve on this if we specify a section in the pipeline at which the total document count will remain the same and insert the limit there removing unnecessary lookup operations.