-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Integration
-
Fully Compatible
Distinct, find, and count all have match expressions and collators inside the CommandRequest object that are stored as BSONObj. The query shape and the executor will expect a match expression, and therefore both will parse the match expression in the "query" field separately if we just pass along a CountCommandRequest for example. During the find/agg project re-parsing the match expression in command requests were a big performance hit. The solution was to have an intermediate representation as a ParsedFindCommand or ParsedDistinctCommand (in this case it would be a ParsedCountCommand), that held all the necessary information for the query shape, parsed the match expression fields and collators, and passed the parsed ASTs to both the query shape and executor. This ticket should create the classes that would allow this so when we are creating the query shape for count we can use this new representation.
General idea here is (Thanks Alyssa for the write up!) :
Okay, I took a look at https://jira.mongodb.org/browse/SERVER-91112. here's what I think we can/should do (basically just what Gil described in the design):
1. Create a class that mirrors ParsedDistinctCommand:
struct ParsedCountCommand { std::unique_ptr<CollatorInterface> collator; std::unique_ptr<MatchExpression> query; std::unique_ptr<CountCommandRequest> countCommandRequest; };
we can use the parsed_distinct_command.* files as a guide
2. Construct this along with the CountCommandRequest in the mongod/mongos count command paths (count_cmd.cpp and cluster_count_cmd.h)
3. Change getExecutorCount to take a ParsedCountCommand instead of a CountCommandRequest directly
4. Instead of passing ParsedFindCommandParams to CanonicalQuery::make in getExecutorCount, use ParsedFindCommand::withExistingFilter to create a ParsedFindCommand to pass along (there is an example of this in CanonicalDistinct::parse)this has some similarities to what is done in https://github.com/10gen/mongo/commit/67b814f955c62a063c8e2142d95cc1bd4386a1d3 but is quite a bit simpler because I don't think we need any kind of CanonicalDistinct class. it should not be too bad at all for Cedric to take on and will set him up with some good context for the rest of the count work, so thank you for bringing up that possibility!
- is depended on by
-
SERVER-90652 Implement query shape for count
- Closed