[SERVER-28177] query_request_helper::asAggregationCommand() should return an AggregationRequest, not a BSONObj Created: 02/Mar/17  Updated: 26/Jul/23  Resolved: 15/Jul/23

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 7.1.0-rc0, 7.0.0-rc8

Type: Task Priority: Major - P3
Reporter: David Storch Assignee: David Percy
Resolution: Done Votes: 0
Labels: read-only-views
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Problem/Incident
Related
is related to SERVER-78875 ParsedDistinct::asAggregationCommand(... Open
is related to SERVER-78874 CountRequest::asAggregationCommand() ... Backlog
Assigned Teams:
Query Optimization
Backwards Compatibility: Fully Compatible
Backport Requested:
v7.0
Participants:
Linked BF Score: 35

 Description   

Since a view is defined by an aggregation pipeline, we convert any count, distinct, or find command request to an equivalent aggregation command.

For the find command, this is accomplished with query_request_helper::asAggregationCommand(). Currently this returns a BSONObj, which we almost always parse immediately into an AggregationRequest. For performance and simplicity, we should change these methods to return a StatusWith<AggregationRequest> directly.

Also, if the caller always uses uassertStatusOK on the result, we can further simplify by returning AggregationRequest directly, and throwing an exception in the error case.



 Comments   
Comment by Githook User [ 15/Jul/23 ]

Author:

{'name': 'David Percy', 'email': 'david.percy@mongodb.com', 'username': 'dpercy'}

Message: SERVER-28177 Avoid re-parsing when converting find to aggregate request

When we get a find request on a view, we first translate it to an
aggregate request, because view resolution works by concatenating
aggregation pipelines. Previously we were converting an already-parsed
FindCommandRequest to a BSONObj, and then parsing that again as an
aggregation. Now we convert directly to AggregateCommandRequest, which
seems simpler and should be more efficient.
Branch: v7.0
https://github.com/mongodb/mongo/commit/539cbe0a645c960ccd4836dee64881a1f7c40c70

Comment by Githook User [ 15/Jul/23 ]

Author:

{'name': 'David Percy', 'email': 'david.percy@mongodb.com', 'username': 'dpercy'}

Message: SERVER-28177 Avoid re-parsing when converting find to aggregate request

When we get a find request on a view, we first translate it to an
aggregate request, because view resolution works by concatenating
aggregation pipelines. Previously we were converting an already-parsed
FindCommandRequest to a BSONObj, and then parsing that again as an
aggregation. Now we convert directly to AggregateCommandRequest, which
seems simpler and should be more efficient.
Branch: master
https://github.com/mongodb/mongo/commit/62b0dfa8ea2ce56594c00e84d6766f19ad0438c0

Comment by David Percy [ 11/Jul/23 ]

Previously this ticket was about all 3 commands: find, count, distinct. I've split off SERVER-78874 and SERVER-78875 to handle count and distinct, and narrowed this ticket to be only about 'find'.

Comment by Xin Hao Zhang (Inactive) [ 04/Jun/19 ]

 

 

Generated at Thu Feb 08 04:17:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.