[SERVER-19152] Reorder $project to be after limits and skips Created: 26/Jun/15  Updated: 26/Jun/15  Resolved: 26/Jun/15

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Craig Wilson Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-12376 $skip and $limit should be moved befo... Closed
Participants:

 Description   

I was looking at the optimizing aggregation pipelines docs page and didn't see this one listed.

I don't know what the cost is to do a bunch of projections only to take the first 3 of them, but reordering the pipeline to push $project before limits and skips would remove the question.

So:

{ $project: { a: 1, b: 1} },
{ $skip: 10 }

would look like this:

{ $skip: 10 },
{ $project: {a :1, b: 1 } }

In addition, doing this might allow further skip/limit coalescence to further optimize the pipeline.


Generated at Thu Feb 08 03:50:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.